1) 此 UCanAccess 示例代码适用于数据库 A (Access 2000)
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection conn = DriverManager.getConnection(DATABASE_URL);
System.out.println(conn);
2) 相同的 UCanAccess 示例代码不适用于数据库 B (Access 2000) 并导致此异常堆栈跟踪:
net.ucanaccess.jdbc.UcanaccessSQLException
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:247)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at XXXXXXXXXX.JdbcAccessConnection.main(JdbcAccessConnection.java:23)
Caused by: java.lang.NullPointerException
at net.ucanaccess.converters.UcanaccessTable.getIndexes(UcanaccessTable.java:74)
at net.ucanaccess.converters.LoadJet$TablesLoader.loadTableIndexesUK(LoadJet.java:794)
at net.ucanaccess.converters.LoadJet$TablesLoader.createIndexesUK(LoadJet.java:835)
at net.ucanaccess.converters.LoadJet$TablesLoader.loadTables(LoadJet.java:921)
at net.ucanaccess.converters.LoadJet$TablesLoader.access$3(LoadJet.java:919)
at net.ucanaccess.converters.LoadJet.loadDB(LoadJet.java:1311)
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:236)
... 3 more
3) 以下 Jackcess 示例代码适用于数据库 B(UCanAccess 不适用)并导致以下输出
Table table = DatabaseBuilder.open(new File(DATABASE_FILE_PATH)).getTable(tableName);
for (Column column : table.getColumns())
{
System.out.println("Column " + column);
}
输出:
Column TextColumn@9234336[
name: (XXXXXXXXXXXXX) Table
type: 0xa (TEXT)
number: 0
length: 100
variableLength: true
compressedUnicode: true
textSortOrder: SortOrder[1033(0)]
]
Column Column@dc8092a[
name: (XXXXXXXXXXXXX) Attached
type: 0x1 (BOOLEAN)
number: 1
length: 1
variableLength: false
]
Column TextColumn@47d1ab77[
name: (XXXXXXXXXXXXX) Database
type: 0xa (TEXT)
number: 2
length: 100
variableLength: true
compressedUnicode: true
textSortOrder: SortOrder[1033(0)]
]
Column TextColumn@16503677[
name: (XXXXXXXXXXXXX) Path
type: 0xa (TEXT)
number: 3
length: 100
variableLength: true
compressedUnicode: true
textSortOrder: SortOrder[1033(0)]
]
有谁知道如何让 UCanAccess 正常工作?在数据库 B 中有很多指向其他 .mdb 文件的链接
4) UCanAccess 错误控制台显示:
Please, enter the full path to the access file (.mdb or accdb): C:\Users\xxx
\Desktop\xxx.mdb
Loaded Tables:
Loaded Queries:
Loaded Indexes:
Primary Key on BERECHTIGUNGEN Columns: (INDEX,USERID)
, Primary Key on DG_FEHLER Columns: (ZAEHLER)
, Primary Key on FEHLERTABELLE_SICH Columns: (FC,BC,SFBEREICH)
, Primary Key on FGJG1_FEHLER Columns: (ZAEHLER)
, Primary Key on GRUNDSCHULEN_LOKAL Columns: (SNR)
, Index Unique on NRW_STRASSEN Columns: (ID)
, Primary Key on PWRD Columns: (USERID)
, Primary Key on SCHULTR─GERART Columns: (SCHULTR─GERART)
, Primary Key on TABELLENZUMHOST Columns: (TABELLE)
, Primary Key on TABELLENZUMHOST_BK Columns: (TABELLE)
, Primary Key on TABELLENZUMHOST_WEITERETABS Columns: (TABELLE,WEITERETABELLE)
, Primary Key on USERID Columns: (USERID)
, Primary Key on USERKONV Columns: (USERID)
, Primary Key on ZFEHLERTABELLE Columns: (FC,BC,SFBEREICH)
net.ucanaccess.jdbc.UcanaccessSQLException
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:24
7)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at net.ucanaccess.console.Main.main(Main.java:151)
Caused by: java.lang.NullPointerException
at net.ucanaccess.converters.UcanaccessTable.getIndexes(UcanaccessTable.
java:74)
at net.ucanaccess.converters.LoadJet$TablesLoader.loadTableIndexesUK(Loa
dJet.java:794)
at net.ucanaccess.converters.LoadJet$TablesLoader.createIndexesUK(LoadJe
t.java:835)
at net.ucanaccess.converters.LoadJet$TablesLoader.loadTables(LoadJet.jav
a:921)
at net.ucanaccess.converters.LoadJet$TablesLoader.access$3(LoadJet.java:
919)
at net.ucanaccess.converters.LoadJet.loadDB(LoadJet.java:1311)
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:23
6)
... 3 more
null
Drücken Sie eine beliebige Taste . . . (en: Press any button to continue . . . )