问题描述
import java.sql.*;
class Test{
public static void main(String ar[]) {
try {
//String url="jdbc:odbc:logingdsn";
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection c=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\aCER\\Desktop\\login.laccdb");
Statement st=c.createStatement();
ResultSet rs=st.executeQuery("select * from logintable");
while(rs.next()){
System.out.println(rs.getString(1));
}
} catch (Exception ee) {
System.out.println(ee);
}
}
}
我正在使用UCanAccess jar文件进行MS Access数据库连接jdk1.8/jre/lib/ext ...
I'm using UCanAccess jar file for ms access db connectivity in jdk1.8/jre/lib/ext ...
我已经包含了所有必需的jar文件,但仍然出现此异常
I have included all required jar files but I'm still getting this exception
及其未加载的驱动程序类.怎么了?
and its not loading driver class. What's wrong?
推荐答案
.laccdb
文件不包含数据库对象(表,视图等).它是Access数据库引擎用来管理与主数据库文件(即 .accdb
文件)的连接的锁定文件.
The .laccdb
file does not contain the database objects (tables, views, etc.). It is a lock file that the Access Database Engine uses to manage connections to the main database file, which is the .accdb
file.
因此,您的连接URL应该指向 .accdb
文件,而不是 .laccdb
文件.
So, your connection URL should point to the .accdb
file, not the .laccdb
file.
这篇关于UcanaccessSQLException:不支持的较新版本:32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!