wood burning stoves 2.0*
The moose likes JDBC and the fly likes jdbc connect Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc connect Access " Watch "jdbc connect Access " New topic
Author

jdbc connect Access

Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
hi,
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(JdbcTest1.java:8)
at JdbcTest1.main(JdbcTest1.java:29)
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)
<CODE>
import java.sql.*;
public class JdbcTest1 {
public void doTest(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
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 ( rs.next() ){
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");
e.printStackTrace();
}
}
public static void main( String[] args ) {
JdbcTest1 test = new JdbcTest1();
test.doTest();
}
}
</CODE>
Brett Spell
Ranch Hand

Joined: Feb 24, 2001
Posts: 96
Simon,
It looks like you have a space (" ") instead of a colon (":") between "jdbc" and "odbc" in your URL. In other words, it should be:
jdbcdbc:Records
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
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc connect Access