bmusical
bmusical

Reputation: 244

"[Microsoft][ODBC Driver Manager] Invalid string or buffer length" error

When I run in eclipse it runs fine. But, through the command prompt, it throws the exception "[Microsoft][ODBC Driver Manager] Invalid string or buffer length". How to get over this?

This is my code:

public static Connection getConnection(){
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String url = "jdbc:odbc:cabrouterds";
        con = DriverManager.getConnection(url, "", "");        
    }
    catch(Exception e)
    {
        System.out.println("SQL Connection Exception: "+e.getMessage());
    }
    return con;
}

Upvotes: 2

Views: 6024

Answers (1)

bmusical
bmusical

Reputation: 244

I'm not sure why it didn't work. Probable guess would be compatibility issues between 64 bit windows 7 and 32 bit MySQL Connector ODBC. Used JDBC - MySQL connector. Now it works.

Upvotes: 2

Related Questions