Get your CodeRanch badge!*
The moose likes JDBC 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
Bookmark "MS Access Database" Watch "MS Access Database" New topic
Author

MS Access Database

Amanda Weber
Greenhorn

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
Greenhorn

Joined: Feb 02, 2003
Posts: 4
G'day
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 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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
Rancher

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
Greenhorn

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

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.
 
 
subject: MS Access Database
 
Similar Threads
I want to know how to use hibernate with Ms Access database
Very Basic Database
sign up and sign in application using struts
MySQL Connection in Eclipse 3.2
connection