File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Accessing a Microsoft Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Accessing a Microsoft Access Database" Watch "Accessing a Microsoft Access Database" New topic

Accessing a Microsoft Access Database

Kevin McNally

Joined: Sep 24, 2003
Posts: 6
So how do you do this step by step?
Say that i've made a database and saved it.
Now what do i do?
I know there are some lines of code to actually open the database in a java application yet are there more steps i have to go through before i can even open it? I tried using some code i got from a site yet had no luck.
So step by step what do I do?
1, I saved the databade
Whats next?
Some code would be helfull too =] Thx alot.
Ajay Chauhan

Joined: Dec 10, 2003
Posts: 5
Hi! Kevin.....
here is ur step by step procedure to connect to an access DB...
1.) Create a system DSN for ur DataBase(*.mdb file)
to learn how to do this u can go thru this WebSite:
2.) In ur java code load the jdbc-odbc bridge driver in the following manner:
3.) Create a connection using :
String url = "jdbc dbc:Ajay";
Connection con = DriverManager.getConnection(url,"myLogin", "myPassword");
where Ajay is ur system DSN name.and if u don't have any passord or login then ur connection variables wud be like this:
String url = "jdbc dbc:Ajay";
Connection con = DriverManager.getConnection(url,"", "");
4.) Next is creating statement objects and resultset objects......For complete info on this u can read the following tutorial..
5.) u can have look at this sample code :
Hope all this helps u solve ur problem.
I agree. Here's the link:
subject: Accessing a Microsoft Access Database
It's not a secret anymore!