JDBC - MS Access - JAR File ... problem

N

nbuserx

I want to read some data from a MS Access DB using the ODBC-JDBC
bridge, but instead of having the DB file seperate I want it
inside my JAR file, so that its only one file to carry around
and the DB file wont get lost anywhere.

But... I cannot get it to work, it always says my path is wrong.

I trying this :
String filename = System.getProperty("java.class.path") +
"/data/MyDB.mdb"; and it does not work.

If there is any solution then please tell me.

Thanks. Asif
 
N

naiki

I want to read some data from a MS Access DB using the ODBC-JDBC
bridge, but instead of having the DB file seperate I want it
inside my JAR file, so that its only one file to carry around
and the DB file wont get lost anywhere.

But... I cannot get it to work, it always says my path is wrong.

I trying this :
String filename = System.getProperty("java.class.path") +
"/data/MyDB.mdb"; and it does not work.

If there is any solution then please tell me.

Thanks. Asif
You can look at this URL http://www.vamphq.com/tutorial.html which
explains how to obtain URL instance for file in package, but still i think
that your way is not good way (file present jar archive is not a file
which has a real path on host filesystem)
 
V

Virgil Green

Netbeans said:
I want to read some data from a MS Access DB using the ODBC-JDBC
bridge, but instead of having the DB file seperate I want it
inside my JAR file, so that its only one file to carry around
and the DB file wont get lost anywhere.

But... I cannot get it to work, it always says my path is wrong.

I trying this :
String filename = System.getProperty("java.class.path") +
"/data/MyDB.mdb"; and it does not work.

If there is any solution then please tell me.

I wouldn't expect to find one. I'm very interested to see if one crops up.

Why don't I expect to find one? The drivers you are talking about don't read
the database directly. They talk to the database engine (Jet, I believe, in
this case) which must, of course, be able to read the database. Jet won't
have a clue how to read inside a jar file.

Since I haven't used Access in some time and have never used the JDBC/ODBC
bridge, I anxiously await all corrections to my misconceptions.
 
N

nbuserx

Thanks naiki, I Dont think there is any way to solve my problem
like Mr Virgil Green said, hes right in saying there is no way (or
easy way) of making the Jet Engine look inside a jar for its
database, then on top of that you have to manage compression and
descompression when you save and load data.

But ur URL will certainly come in handy some something else.

Thanks Again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,823
Latest member
Nadia88

Latest Threads

Top