adesh singh
adesh singh

Reputation: 1727

connection string of jdbc odbc with MS access

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)

Upvotes: 2

Views: 14742

Answers (1)

adesh singh
adesh singh

Reputation: 1727

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);
}

Upvotes: 4

Related Questions