Unable to connect to a database on a shared drive - UCanAccess

こ雲淡風輕ζ 提交于 2019-12-01 22:34:12

You simply don't have enough forward slashes in your connection URL to represent a UNC path. As you have noted, for a local connection to C:\Desktop\MyDB.accdb you can use

String databasePath = "jdbc:ucanaccess://C:/Desktop/MyDB.accdb";

Similarly, for a UNC connection to \\servername\etc\MyDB.accdb you can use

String databasePath = "jdbc:ucanaccess:////servername/etc/MyDB.accdb";

The database driver can only handle his specified protocolls. Most of jdbc drivers can only handle the network protocol for his specific database server.

You are using the access jdbc driver which can only handle file access to a given accdb file.

When you try an url like:

jdbc:ucanaccess://servername/etc/MyDB.accdb

The driver makes a local file access to this path which does not exist localy. What you expect is, that the driver would make up a SMB/CIFS connection to your server, which he can't!

You have to map the SMB/CIFS share over your OS on to a local drive letter. Because then the OS is handling the network SMB/CIFS stuff for you. And the JDBC driver can access the file as it would access a local file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!