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

jdbc connect Access

Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
I am new to JDBC. I tried to connect to MS Access, but always give the following error:
C:\>java JdbcTest1
Error Creating Record
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JdbcTest1.doTest(
at JdbcTest1.main(
I try to look through all the threads, but unable to solve it.
Please help. I use jdk 1.3 . I did go to settings->control panel to create a DSN.
Here is the program (taken from this forum)
import java.sql.*;
public class JdbcTest1 {
public void doTest(){
Connection con = DriverManager.getConnection("jdbc odbc:Records","","") ;
Statement stmt = con.createStatement();
System.out.println("Table Created?"+stmt.executeUpdate("create table mytable (sno integer, name varchar(20) )"));
System.out.println("Inserted?"+stmt.executeUpdate("insert into mytable values (1, 'Silly')"));
System.out.println("Inserted?"+stmt.executeUpdate ("insert into mytable values (2, 'Ken')"));
ResultSet rs = stmt.executeQuery("select * from mytable");
while ( ){
System.out.println("SNO ==>"+rs.getInt("sno")+"\n");
System.out.println("SNO ==>"+rs.getString("name")+"\n");
}catch (Exception e){
System.out.println("Error Creating Record");
public static void main( String[] args ) {
JdbcTest1 test = new JdbcTest1();
Brett Spell
Ranch Hand

Joined: Feb 24, 2001
Posts: 107
It looks like you have a space (" ") instead of a colon (":") between "jdbc" and "odbc" in your URL. In other words, it should be:
instead of:
jdbc odbc:Records
The error message you received indicates that no registered driver understands the URL you specified, which in this case is because the URL is incorrect.
Brett Spell
Author, Professional Java Programming
[This message has been edited by Brett Spell (edited March 21, 2001).]
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi, Brett,
After changing the space, it works now. Thanks
It is sorta covered in the JavaRanch Style Guide.
subject: jdbc connect Access
It's not a secret anymore!