• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dah Foh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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: https://coderanch.com/t/546920/JDBC/databases/JDBC-MS-Access-without-ODBC.
 
Dah Foh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:
Oh, is that all? Then I think your question was fully covered in this Ranch post from last year: https://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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul, what's a good choice of a database that you would pick other than MS Access?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At present I'm not taking consulting assignments.
 
Dah Foh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:At present I'm not taking consulting assignments.



What does this mean, Paul?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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. :)
 
reply
    Bookmark Topic Watch Topic
  • New Topic