aspose file tools
The moose likes Java in General and the fly likes packing an acces file with my jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "packing an acces file with my jar" Watch "packing an acces file with my jar" New topic
Author

packing an acces file with my jar

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3359

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 ?
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
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???


SCJP 1.4, www.gsi3d.org.uk
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.


42
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: packing an acces file with my jar
 
Similar Threads
Jdbc driver not found when putting an application in a jar-file
Adding Database to application
Jar files & JarOutputStream
Get com.sun.net.httpserver package
Using MS ACCESS in a jar file