[英]connection string of jdbc odbc with MS access
我正在嘗試通過ms訪問建立jdbc odbc連接,但無法傳遞由特殊字符組成的密碼
I am using the following code
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("Jdbc:Odbc:Driver={Microsoft Access
Driver(*.mdb); DBQ=d:/abc/xyz.mdb};","","password here");
Statement st=con.createStatement();
}
catch(Exception ex)
{
}
但這即使在密碼非常復雜(特殊字符組合)的情況下也無法識別密碼
JDBC-ODBC的以下連接字符串正常運行。
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connectionQuery="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=path upto the database;uid=; pwd=password here;";
con = DriverManager.getConnection(connectionQuery,"","");
st=con.createStatement();
stmt=con.createStatement();
}
catch(Exception ex)
{
System.out.println("exception is"+ex);
}
您使用的是32位還是64位Windows? 每個URL字符串都不相同:
http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/
使您的URL看起來像本文中的URL一樣,否則您將遇到問題。
空的捕獲塊總是一個壞主意。 您將不知道是否引發異常。 打印堆棧跟蹤記錄需要多少工作?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.