且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法通过JDBC驱动程序连接到* .dbf文件

更新时间:2023-11-23 07:54:16

好,我终于找到了解决我所有问题的答案。



无需配置ODBC数据源,该代码中的错误是我直接针对的在我的连接字符串中,我要访问的文件名。
(在这里的代码中,我删除了 \CARISTAT)。



因此应用程序易于运行,并且没有更多的JDBC驱动程序错误! / p>

仍然感谢您的支持!


i'm trying to connect to *.dbf (dBase III) file on my Java application, running on a Windows Server 2003 system. I'm encountering this error and I cannot really understand the meaning (sources for OdbcJdbc.java seems to be unavailable):

[Microsoft][ODBC dBase driver] '(unknown)' is not a valid path error

This is the code I run on my application:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

String database = "jdbc:odbc:DRIVER={Microsoft dBase Driver(*.dbf)};DBQ=D:\\dbNeri\\CARISTAT;";

Connection conn = DriverManager.getConnection(database);

Statement s = conn.createStatement();
String selTable = "SELECT * FROM CARISTAT";

Does it exists a JDBC driver able to connect to dBase files or do I have to import external libraries to do the magic?

Thanks in advance for your help!

Ok guys, I finally found the answer to all my problems.

Without any need to configure a ODBC data source, the mistake in that code was I've targeted directly in my connection string the file name I would like to access. (In the code up here, I removed "\CARISTAT").

Thus the application run easily and with no more JDBC driver error!!

Thanks anyway for your support!