import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.SQLException;
public class access{
//网桥JDBC/ODBC驱动程序
private static String DBDRIVER="sun.jdbc.odbc.JdbcOdbcDriver";
//数据库URL
private static String DBURL = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Documents and Settings\\sms.mdb";
public static void main(String[] args) {
Connection con = null;
Statement stmt = null;
String createString = "create table student"+"(ID INTEGER,NAME char(8),grade NUMBER,class char(10))";
try {
Class.forName(DBDRIVER);//加载驱动程序
//建立与数据库的连接
con=DriverManager.getConnection(DBURL);
}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException:" + e.getMessage());
System.exit(1);//终止应用程序
}
catch (SQLException ex) {
System.out.println("SQLException:" + ex.getMessage());
System.exit(1);//终止应用程序
}
try {
stmt=con.createStatement();//创建SQL语句对象
stmt.executeUpdate(createString);//执行SQL语句
System.out.println("在SMS数据库创建表student成功");
}
catch (SQLException ex){
System.out.println("SQLExcepion:" + ex.getMessage());
}
finally {
if (stmt != null) {
try {
stmt.close();//关闭语句
}
catch (SQLException e) {}
}
if (con != null) {
try {
con.close();//关闭与数据库的连接
}
catch (SQLException e) {}
}
}//try/catch/finally块结束
}//main方法结束
}
运行结果总是显示SQLException:[Microsoft][ODBC Microsoft Access Driver] 找不到文件 '(未知的)'。已经建立了access数据源,有office软件,求高手指点一下呀