I am trying to make jdbc odbc connection with ms access
but not able to pass the password which is consisted from special characters
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)
{
}
but this is not recognising the password here even the password is much complex (combination of special characters)
Following connection string for JDBC-ODBC is working correctly.
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);
}
Are you using 32-bit or 64-bit Windows? The URL string is different for each one:
http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/
Make your URL look just like the ones in this article or you'll have problems.
Empty catch blocks are always a bad idea. You won't know if an exception is thrown. How much work is it to print the stack trace?