主题:JDBC-ODBC数据库连接错误,回答就给分。
源程序如下:
import java.sql.*;
public class TestDB {
public static void main(String[] args) {
String jDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String conURL = "jdbc: odbc: TestDB";
try {
Class.forName(jDriver);
Connection con = DriverManager.getConnection(conURL);
Statement s = con.createStatement();
s.close();
con.close();
}catch (Exception e) {
e.printStackTrace();
}
}
出现错误
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at TestDB.main(TestDB.java:18)
未找到合适的驱动???是sun.jdbc.odbc.JdbcOdbcDriver不对吗?请问是怎么一回事?
import java.sql.*;
public class TestDB {
public static void main(String[] args) {
String jDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String conURL = "jdbc: odbc: TestDB";
try {
Class.forName(jDriver);
Connection con = DriverManager.getConnection(conURL);
Statement s = con.createStatement();
s.close();
con.close();
}catch (Exception e) {
e.printStackTrace();
}
}
出现错误
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at TestDB.main(TestDB.java:18)
未找到合适的驱动???是sun.jdbc.odbc.JdbcOdbcDriver不对吗?请问是怎么一回事?