I am using java with Sybase as backend. I have a field in table which stores varchar of around 400 characters. Now when I am creating a resultset in java and calling resultset.getString(1), it only returns 255 characters and remaining characters are lost. As per my knowledge there is no restriction on getString() in terms of data retrieval, atleast not 255 characters.
Any solution to this? I have also tried using getObject() and getBinaryStream() instead of getString(), it retrieves same 255 characters.
It's probably the JDBC driver that's truncated they data on the request. Take a look at the configuration options and documentation for the JDBC driver and see if there is a max character limit of some kind. Often times you can resolve such issues by increasing the maximum size the driver will handle by adding a parameter to the connection string.
You can also try reading the data as a stream and seeing if you get over 255 characters.
The issue has been resolved. I added JCONNECT_VERSION=6 in following JDBC URL jdbc:sybase:Tds:mrf-dbr2-dev.com:5050/scenario?JCONNECT_VERSION=6 and it works. By default JCONNECT_VERSION is set as 5 which restricts the data limit to 255 characters. Thanks guys.
avijit majumder wrote:hi
Yes boss there is no any restriction of character langth of
getString(1) method of java
But there can definitely be a restriction on the JDBC driver, as I believe Sandeep discovered. Since JDBC drivers are often thought of as black boxes, there's really no reason to think any of them behave the same. In this case, getString() is a method executed by the JDBC driver against a class that implements a ResultSet, so it can do strange things as Sandeep saw.
Sandeep P Parmar
Joined: Oct 20, 2009
Is it possible to retrieve the full String without changing JCONNECT_VERSION to 6? I have restriction in project which limits me to use JCONNECT_VERSION=5.
As you saw in your tests, not really. You can try reading the data as a stream instead of getString but that's not likely to work. You could also try using 'clever' SQL string functions to cut up the text in the query although the performance of that is liable to be awful.
This is one of those situations you either need to demand to use JCONNECT_VERSION=6 or tell them no table can have a column larger than 255 characters. There's really no in-between (can't make gold from lead anyway)
subject: getString() does not retrieve String bigger than 255 characters