代码:
String fileToBeRead = "d:\test\";
String strAccessName = "test.mdb";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String urlAccess = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + fileToBeRead + strAccessName;
System.out.println("urlAccess=" + urlAccess + "\n");
System.out.println("dddd");
connAccess = DriverManager.getConnection(urlAccess);
System.out.println("eeee");
}
catch(ClassNotFoundException e){
System.out.println("JDBC驱动[sun.jdbc.odbc.JdbcOdbcDriver]未发现" + "\n" );
}
catch(SQLException se){
System.out.println("Access数据库连接失败!" + se + "\n");
}
catch(Exception ce){
System.out.println("有错:" + ce.toString());
}报错清息:
String fileToBeRead = "d:\test\";
String strAccessName = "test.mdb";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String urlAccess = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + fileToBeRead + strAccessName;
System.out.println("urlAccess=" + urlAccess + "\n");
System.out.println("dddd");
connAccess = DriverManager.getConnection(urlAccess);
System.out.println("eeee");
}
catch(ClassNotFoundException e){
System.out.println("JDBC驱动[sun.jdbc.odbc.JdbcOdbcDriver]未发现" + "\n" );
}
catch(SQLException se){
System.out.println("Access数据库连接失败!" + se + "\n");
}
catch(Exception ce){
System.out.println("有错:" + ce.toString());
}报错清息:
java.lang.NullPointerException
前面的定义写错了
System.out.println(connAccess);
打印一下,看看你取到connection美哦于
ress/200607130507.mdb
这里已报错,下面打印不下去了
会不会是没装access呀??
解决了
装了jdk就好了
谢谢各位