aspose file tools*
The moose likes JDBC and the fly likes Adding Database to application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Adding Database to application" Watch "Adding Database to application" New topic
Author

Adding Database to application

Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
Here i am using my database with in my application



/MultiFucntioner/src/main/TelephoneBook.mdb
My class is also in this main package

Multifunctioner is the application name
src is the folder
main is the package
Telephone.mdb is the database name

my database is in a package and in this same package i have my database class too
I am using this code to access the database


if i am using this code than it will run but when i am trying to make the jar eclipse will not include this so that i am using the Url




error what i an getting is

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
I'm fairly certain that ODBC needs an actual MDB file, not something that's inside of a jar file.


Ping & DNS - my free Android networking tools app
Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
From the first code my application runs perfectly

but i want to use it through URL because as like images if we use them directly in jar they are worthless but if we use them through URL than it will work

same is here i am using the database directly and it is establishing connection work perfectly but when i make the jar there is exception

so taht i want to use it through URL
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
It may be that that's what you want, but as I said, it's not going to happen. If you want to ship a DB file as part of your application's jar file, check out HSQLDB which can access a read-only DB in a jar file through JDBC.
Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
Tell me if its working through first code than why it is not working from second code

ohk than tell me the way so that i can establish the connection to the ODBC services through the code
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Tell me if its working through first code than why it is not working from second code

Logically, there's no reason why something that works through files should also work through the resource loading mechanism. And in this case, there is a very good reason why it would NOT work, namely that DBs are generally read/write resources, and write access is not possible for resources in jar files. That's rather different from images which are most often read, but not written.

ohk than tell me the way so that i can establish the connection to the ODBC services through the code

You need to ship the MDB file along with the jar file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding Database to application