and this is the code im using.
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){
e.printStackTrace(System.err);
}
Connection con;
Statement stmt;
//connecting to the database.
try{
con=DriverManager.getConnection("jbdc:odbc:Hw3");//this is where
its giving me errors
stmt=con.createStatement();
con.close();
stmt.close();
}
catch(Exception sqle){
sqle.printStackTrace(System.err);
}
any suggestions do i have to download any updates or something im
using java 1.5 sdk.
> Im trying to connect my database. im using ms access when i try to
> execute my program it gives me this error
> i create my database by going to the odbc in the administrative tools.
> and when i try to execute my code it gives me this error:
> java.sql.SQLException: No suitable driver
[snip]
> con=DriverManager.getConnection("jbdc:odbc:Hw3");
Look closely on how you have spelled "jdbc"...
> any suggestions do i have to download any updates or something im
> using java 1.5 sdk.
Configuring a dsn in Windows, and relying on that dsn-name in your code, can
make your app less portable, than when calling the driver in a more "direct"
way.
Short example:
String url =
"jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=mydb.mdb";
Connection con = DriverManager.getConnection (url);
/// Bjorn A
Try This connection and update me
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dataSourceName = "Address.mdb";
String dbURL = "jdbc:odbc:Driver={Microsoft Access
Driver (*.mdb)};DBQ=";
dbURL += dataSourceName +
";DriverID=22;READONLY=true)";
dbconn = DriverManager.getConnection(dbURL,"","");
Statement s = dbconn.createStatement();
}
catch ( ClassNotFoundException cnfex )
{
cnfex.printStackTrace();
info=info+"Connection unsuccessful\n" + cnfex.toString();
}
Indika