简体   繁体   English

使用UCanAccess代替JDBC-ODBC Bridge来处理DBF文件

[英]Using UCanAccess instead of the JDBC-ODBC Bridge for working with DBF files

I'm using NetBeans IDE 8.2 and would like to make a connection with UCanAccess to access my database files. 我正在使用NetBeans IDE 8.2,并想与UCanAccess建立连接以访问我的数据库文件。 Initially I was using jdbc:odbc but I found that Java 8 onward no longer supports this method 最初我使用的是jdbc:odbc但是我发现Java 8及更高版本不再支持此方法。

Here is my initial coding : 这是我的初始编码:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:vABCD");

Here is the code after the changes : 这是更改后的代码:

 Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
con = DriverManager.getConnection ("jdbc:ucanaccess://C:\\Users\\questionasker\\Desktop\\database");

but I get the error : 但我得到了错误:

net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.2 C:\Users\questionasker\Desktop\database (Access is denied)
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:264)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at vhrmsrptgen.AnnualAppraisal.connect(AnnualAppraisal.java:41)
at vhrmsrptgen.AnnualAppraisal.generate(AnnualAppraisal.java:90)
at vhrmsrptgen.MainFrame.btnGenerate_actionPerformed(MainFrame.java:368)
at vhrmsrptgen.MainFrame_btnGenerate_actionAdapter.actionPerformed(MainFrame.java:583)

My database files are all in .DBF format (which are very old files) and all files are under this directory : 我的数据库文件都是.DBF格式(都是很旧的文件),所有文件都在此目录下:

C:\\Users\\questionasker\\Desktop\\database

What can I do in order to make the coding correct to connect the database? 为了使编码正确以连接数据库,我该怎么办?

My database file all is in .DBF format 我的数据库文件全部为.DBF格式

UCanAccess is not a general-purpose replacement for the JDBC-ODBC Bridge. UCanAccess不是JDBC-ODBC Bridge的通用替代品。 It is a JDBC driver specifically for working with Microsoft Access database files ( .mdb , .accdb , and related variants). 它是一个JDBC驱动程序,专门用于处理Microsoft Access数据库文件( .mdb.accdb和相关变体)。 It is not designed to work with .dbf (dBASE) files. 它不适用于.dbf (dBASE)文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM