Problems connecting to database using Java.

Q

questionmarc420

hi,
im having toruble connecting to MS Access DB using Java.
This is the code i used:

public void connect(){

try {
Class.forName("sun.jdbc.odbc.JbdcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}


String databaseName = "invent";
String url = "jdbc:eek:dbc:" + databaseName;
String loginName = "Admin";
String password = "lace";


try {
conn01 = DriverManager.getConnection(url,
loginName, password);
} catch (SQLException e) {
e.printStackTrace();
}
}



this is the error i get:

java.lang.ClassNotFoundException: sun.jdbc.odbc.JbdcOdbcDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at allm.test.DBaccess.connect(DBaccess.java:18)
at allm.test.test.main(test.java:17)
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at allm.test.DBaccess.connect(DBaccess.java:29)
at allm.test.test.main(test.java:17)


can somebody please pooint me in the right direction.
do i need to configure somethign in access? is there any thing i have
to do in the ODBC configurations?

any help is appreciated.
thanks in advance
-morc
 
D

Douglas J. Steele

Sorry, but I think you're going to need to ask in a Java-related newsgroup.

Realistically, you're not using Access: you're attempting to connect to a
Jet database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top