2

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

データベースは永続化ユニットとしても接続されていますが、コード内からそれを利用する方法を知らないため (Google は役に立ちませんでした)、この方法が私の唯一の選択肢のようです。

4

1 に答える 1