GeeCON Prague 2014*
The moose likes JDBC and the fly likes [Microsoft][ODBC Driver Manager] Invalid string or buffer length exception for 64 bit SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "[Microsoft][ODBC Driver Manager] Invalid string or buffer length exception for 64 bit SQL Server" Watch "[Microsoft][ODBC Driver Manager] Invalid string or buffer length exception for 64 bit SQL Server" New topic
Author

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

Tulika Garg
Greenhorn

Joined: Mar 27, 2009
Posts: 6
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.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

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


Swastik
Tulika Garg
Greenhorn

Joined: Mar 27, 2009
Posts: 6
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
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

See if this helps some way

http://support.microsoft.com/kb/942976
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Steve Simon
Greenhorn

Joined: Jan 28, 2012
Posts: 12
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!
Marinos Mavrommatis
Greenhorn

Joined: Dec 17, 2013
Posts: 1
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.
 
GeeCON Prague 2014
 
subject: [Microsoft][ODBC Driver Manager] Invalid string or buffer length exception for 64 bit SQL Server