This discussion is archived
3 Replies Latest reply: Jan 19, 2011 9:44 AM by 814624 RSS

sun JdbcOdbc bridge can not connect to ODBC DSN on win2008 64bit platform

843859 Newbie
Currently Being Moderated
I am using sun JdbcOdbc bridge to connect to ODBC DSN on windows2008 64 bit platform. But it throws exception as following:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.buildTypeInfo(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

My source code is:
1. Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

2. Connection con = DriverManager.getConnection("jdbc:odbc:testdsndb","sysadm","");

3. System.out.println(con);

4. String dbname = con.getCatalog();

5. System.out.println("database name: " + dbname);

When the code execute to line 2, it throws exception.
I use window 2008 64 bit simple chinese platform. I tried jdk1.5, 1.6 64bit ,there are all have this problem.
Does anyone help me to solve this problem? And why that problem?

Thanks a lot!
  • 1. Re: sun JdbcOdbc bridge can not connect to ODBC DSN on win2008 64bit platform
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    kris1229 wrote:
    I am using sun JdbcOdbc bridge to connect to ODBC DSN on windows2008 64 bit platform.
    A DSN defines the source to connect to. It is not the source.
    But it throws exception as following:
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
    As a guess DSN is corrupted or otherwise wrong. Delete it, recreate it using the ODBC applet. And then test it in that applet.

    Presumably you did not create it by copying it from a 32 bit source (neither the DSN nor the associated ODBC driver.)
    Connection con = DriverManager.getConnection("jdbc:odbc:testdsndb","sysadm","");
    Try null for the last value.
  • 2. Re: sun JdbcOdbc bridge can not connect to ODBC DSN on win2008 64bit platform
    814624 Newbie
    Currently Being Moderated
    Your really close to having it work. Some things to remember:

    1. On 64-bit windows it is possible to install both 32-bit and 64-bit Office 2010. You should be sure of your operating system architecture as well as the architecture of the Access driver your using.

    2. There are 2 ODBC control panels: one for 64-bit drivers and one for 32-bit drivers (in the WOW64) directory. Don't trust them entirely though... I could swear that the User and System DSN panels sometimes don't operate on the correctly architectured driver and so just be aware to be extra sensitive when looking at that stuff. To be safe, just use "System" dsn's.

    3. When running the 64-bit ODBC control panel, the Access driver you should be using appears like
    "Source=jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Core.mdb" . the 32-bit driver wont have the "*.accdb" part.

    I've tried increasing the buffer in the ODBC properties up to 16K and it didn't solve the issue when I saw it. I also tried using the "Repair" option in the 64-bit OBDC control panel to repair the access database and it didn't work either. The access database originally came from a Office 2000 system but I can't imagine that is the problem.
  • 3. Re: sun JdbcOdbc bridge can not connect to ODBC DSN on win2008 64bit platform
    814624 Newbie
    Currently Being Moderated
    Just discovered that the new Access 2010 driver that is available since Dec 16, 2010 (for download) fixes the problem for me.