• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[Microsoft][ODBC Driver Manager] Invalid string or buffer length exception for 64 bit SQL Server

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have created a system DSN using ODBC administrator to connect to SQL Server 2008 database using SQL Server Native Client 10.0.

My system configuration is :
Windows Server 2008 R2 64 bit
SQL Server 2008 64 bit
JDK 6.0.18 64 bit

Now when I try to connect to database using this DSN and JDBC-ODBC bridge, I get the following exception:

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)

The same code works fine on my 32 bit machine. Could it be an issue with the ODBC JDBC bridge or am I doing something wrong here?

Tulika.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try with some other driver instead of sql server native client 10.0? You may have a look on this

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=000364db-5e8b-44a8-b9be-ca44d18b059b&displaylang=en
 
Tulika Garg
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Swastik. As per the article you sent me, MSDASQL ships with the Windows Server 2008 and I also tried with this Driver, only to get the same exception.

Tulika.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this helps some way

http://support.microsoft.com/kb/942976
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JDBC-ODBC bridge should be your driver of last resort. ODBC is a horribly inefficient protocol to begin with, and the JDBC bridge was never intended for use in serious processsing environments, so it's not going to be exploiting too many ODBC optimizations.

Any major database that doesn't have a native JDBC driver probably shouldn't be used for production work. In particular, the MS-Access and FoxPro databases aren't suitable for use with webservers, since webservers run multi-threaded and neither MS-Access nor FoxPro were designed for that.

SQL server has several JDBC drivers to choose from. You used to only be able to get a SQL Server driver by buying it from a third party such as WebLogic, but Microsoft finally broke down and supplied one of their own. As of 2 years, ago, however, it had some serious deficiencies, so I've been using the open-source JDBC driver available on sourceforge.net. MS may have fixed their problems by now, but I don't know.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The MS driver is OK these days. Once they had swapped away from the one they used to supply, which was licensed from a very old cut of DataDirect code I think (and couldn't be maintained because of this), things got better. jTDS is still my preferred JDBC driver for SQL Server, but there's not much between the two these days.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can say, with absolute certainty that this is a 64 bit issue.
Rolling over to a 32 bit OS is the only solution I have found.

I must say this driver is VERY annoying.
In fact, I received the same error message when attempting to add another (unused) argument onto the method to which the SQL statement belonged.
If that doesn’t blow one’s mind, I don’t know what does!
 
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For me it turned out to be an encoding issue, even though it appeared to be a 64 bit issue!
Updating to 4D version 14 fixed it.

The problem appeared only when I switched to a 64bit machine and installed 4D v13. On my 32bit machine I was using 4D v11 and had no problems.
Printing out the results of my query revealed that on my 64bit machine they were not decoded correctly. Hence the

Invalid string or buffer length

error.
Going into the ODBC Data Source Administrator and then in 4D's Driver Configuration and switching the encoding between System and UTF-8 did NOT fix the issue.
Finally, updating my 4D Driver to v14 fixed it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic