haoyue
发贴: 24
积分: 0
|
于 2004-08-04 15:12
我在运行一个连接到Access数据庫的java程序时,出了如下错误,能帮我想想办法吗? 错误是: Can not load jdbc--odbc Bridge Driver ClassNotFoundException:sun/jdbc/odbc,jdbcOdbcDriver SQLException: Message:No suitable driver 程序是: import java.net.URL; import java.sql.*;
class StudentAccess { public static void main(String args[]) { String url="jdbc:odbc:Student"; //Student是已经建立的ODBC数据源名称 try { try { //加载JDBC-ODBC Bridge驱动程序 Class.forName("sun.jdbc.odbc,jdbcOdbcDriver"); //sun.jdbc.odbc.jdbcOdbcDriver是jdbc--Odbc桥在JDK中的类名, //要注意的是,在不同的开发环境中,是驱动程序的类可能包含在不同的包里 } catch(java.lang.ClassNotFoundException e) { System.out.println("Can not load jdbc--odbc Bridge Driver"); System.err.print("ClassNotFoundException:"); System.err.println(e.getMessage()); } Connection con=DriverManager.getConnection(url); //使用指定的url连接数据库 DatabaseMetaData dmd=con.getMetaData(); System.out.println("连接的数据库:"+dmd.getURL()); System.out.println("驱动程序:"+dmd.getDriverName()); } catch(SQLException ex) { System.out.println("SQLException:"); while(ex!=null) { System.out.println("Message:"+ex.getMessage());//打印出错信息 ex=ex.getNextException(); } } } } 另外,请问我能到哪下载到一些常用的数据库的驱动程序呢?(如:Access、SQL sever 2000等的) 望大家多指教。
|