I have swing application that uses an access database. if I want to package my appliction into an executable jar format, then can I package this database(access file) along with my application ?
John, I guess you can as the jar is just a zip file so you can put whatever you want in it. However, if maybe you are using JDBC to do queries on the database I think the user will still have to extract it from the jar and set up an ODBC datasource on their PC. Not sure how you'd get around that But I'm not a JDBC expert so maybe someone else has a suggestion for accessing the DB inside the jar???
You cannot access the Access database from inside the jar as Access could never find it there to access it. You would indeed also need to set up an ODBC reference on the client machine, but any halfway decent installation program should be able to help you do that. It can also put the mdb somewhere for the reference to find (Access ODBC references refer to a physical file location so it needs the file location anyway) and create a shortcut to launch your jar from the desktop.
John, You can jar up just about any ol' files you want to include in your executable JAR. As mentioned, if you're wanting an Access database engine on the client machine to make use your Access database file, you'll have some more work ahead. Depending what you're trying to do, you might prefer to make use of an embedded database system like hsqldb.
Even using hsql the datafiles themselves will need to be outside the jar, certainly when they're not to be read-only (hsql might support reading a readonly database that resides inside a jar, you'd have to look that up). A better mechanism would be to include a function in the installer or program which creates the actual database on the fly during installation or when first run. This can use a datafile which CAN reside inside the jar and create the database based on that file outside the jar.
Post by:autobot
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking