我遇到了 UCanAccess 驱动程序的问题,即当我尝试使用以下代码连接到数据库时
public static void main(String[] args) {
//establish connection with database in order to execute sql queries
try {
conn = DriverManager.getConnection("jdbc:ucanaccess://H:\\IT_PAT_Program_LOCALONLY\\IT_Pat_Database.accdb;showschema=true");
System.out.println("Connection Established");
} catch (SQLException ex) {
System.out.println("Could Not Connect to database\n"+ex);
}
//closes the database connection at program shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
conn.close();
System.out.println("Shutdown Succesful");
} catch (SQLException ex) {
System.out.println("An exception occured\n"+ex);
}
}
});
}
我遇到以下错误:
Could Not Connect to database
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.0 invalid authorization specification - not found: Admin
数据库也作为持久性单元连接,但是由于我不知道有任何方法可以从代码中使用它(谷歌没有帮助),这种方法似乎是我唯一的选择。