my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes MS 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 "MS Access Database" Watch "MS Access Database" New topic

MS Access Database

Amanda Weber

Joined: Nov 20, 2002
Posts: 28
Can someone give me step by step instructions on how to use an access database from java. Starting with creating the odbc connection. I only want the database on my home PC?
Mohammed Ali

Joined: Feb 02, 2003
Posts: 4
Well what I would do is
1- Learn how to setup an ODBC that points to a Microsoft Access database
Check this website(first half of it)
ODBC setting
2- Go back to you JSP
The URL speifying how to connect to Microsoft ODBC database using JDBC
2-1 Load the driver to connect to the database
// some java code
// the unhappy face is simply : followed by O
// I assumed that u named the OBDC as AmandaODBC
String url = "JDBC DBC:AmandaODBC";
// the name and password u used when u created the ODBC
String password ="youpassword";
String username ="youname";
try {
Connection myConnection = DriverManager.getConnection(url,username, password);
} catch( ClassNotFoundException cnfex) {
// some error messages here
System.err.println("Failed to conenct to JDBC/ODBC driver")
System.exit(1); // terminates the program
The rest should be normal JDBC code, u used the myconnection object to creat statement and use resultset to use the statement...........
Hope that helps...

[ February 02, 2003: Message edited by: Aussie man ]
[ February 02, 2003: Message edited by: Aussie man ]
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

"Aussie man"
We're pretty light on rules at the ranch, but the naming policy is one that we enforce.
Please check it out here and change your display name to comply. You ned to have your frst name, a space then your last name and obviously fictitious names aren't allowed.
Please change your display name soon, since accounts with invalid display names get deleted
and welcome!
Dave (aka the other Aussie man )
Mohammed Ali

Joined: Feb 02, 2003
Posts: 4
Thanks 4 letting me know David.
[ February 03, 2003: Message edited by: Mohammed Ali ]
Jeff Hancock

Joined: Nov 17, 2000
Posts: 11
I have the proper ODBC System DSN setup and i stil receive the error. My classpath is set for rt.jar. I installed MDAC 2.7.
It is sorta covered in the JavaRanch Style Guide.
subject: MS Access Database
jQuery in Action, 3rd edition