aspose file tools*
The moose likes JDBC and the fly likes How to conncet to MS Access database2007 from a java app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to conncet to MS Access database2007 from a java app?" Watch "How to conncet to MS Access database2007 from a java app?" New topic
Author

How to conncet to MS Access database2007 from a java app?

Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Hi guys,

I hope you can help me with this. Is there any way to conncet to MS Access2007 database from a java app without having to do the config for every machine when deploying the app? What is the best way of doing so? I heard about the pure java driver i.e. the type 4 but have no idea how to use it!

I use eclipse by the way.

Please try to help. Any effort will greatly be appreciated.

Thanks.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2596
    
    9

Welcome to the Ranch

First MS Access is a MS product and ODBC drivers usually work with such products. If there is indeed a type 4 JDBC driver for Access, then you should read their doc for connection, querying etc.

If there is no type 4 driver, then using the traditional ODBC-JDBC bridge (eg type 1 driver) will at least get you going.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Thank you, Tsnaq, for your reply. I don't want to use JDBC:ODBC because I have to do give the database file location every time I deploy the app to a different machine! I found the hxtt as a type4 driver but I don't know how to chane the classpath- anyone can help please.

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Dah Foh wrote:I don't want to use JDBC:ODBC because I have to do give the database file location every time I deploy the app to a different machine!


Oh, is that all? Then I think your question was fully covered in this Ranch post from last year: http://www.coderanch.com/t/546920/JDBC/databases/JDBC-MS-Access-without-ODBC.
Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Paul Clapham wrote:
Oh, is that all? Then I think your question was fully covered in this Ranch post from last year: http://www.coderanch.com/t/546920/JDBC/databases/JDBC-MS-Access-without-ODBC.


Thank you, Paul, for your reply. I think I found a way to do it through a type4 driver called HXTT Access Pure Java JDBC Driver. It can be downloaded from here

I downloaded version 4.0 which is compatible with 1.6 JDK and this is how it is setup.

1- Download the file, unzip it then go to the lib directory and copy the jar file to your project workspace.
2- In Eclipse open your project, then go to run menu- run configurations then in the classpath tab you can add the jar file using the (add external jars) button.
3- You need to change the url string of your database file. For example if you're using Access2007 then you change it to:

String url= "jdbc:access:/./nameOfYourDatabase.accdb";


For further information please visit the HXTT documentation whcih can be found in the file you downloaded from the link above.


Thanks.



Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Paul, what's a good choice of a database that you would pick other than MS Access?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

That depends on your requirements, but if one of the requirements is "Must access database from Java" then I would use almost any database rather than Access.
Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Paul Clapham wrote:That depends on your requirements, but if one of the requirements is "Must access database from Java" then I would use almost any database rather than Access.


No special requirements except being robust, free, easy to use (no many configs), about 200 users. Which database would you choose?

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

At present I'm not taking consulting assignments.
Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Paul Clapham wrote:At present I'm not taking consulting assignments.


What does this mean, Paul?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Under other circumstances you might be able to hire me to advise you about what database server you might choose, based on a review of your requirements. But at the present time you can't do that.
Dah Foh
Greenhorn

Joined: Sep 15, 2012
Posts: 7
Paul Clapham wrote:Under other circumstances you might be able to hire me to advise you about what database server you might choose, based on a review of your requirements. But at the present time you can't do that.


The trouble is that I don't have business and not intend to have one. I'm just trying to learn things. I thought this forum was to share knowledge. Hopefully, another gentle code rancher will come along and share their knowledge.

Thank you, Paul. :)
 
Consider Paul's rocket mass heater.
 
subject: How to conncet to MS Access database2007 from a java app?