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

此生再无相见时 提交于 2019-12-02 03:30:32

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/8187827/microsoftodbc-driver-manager-invalid-string-or-buffer-length-error

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