• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1800
  • Last Modified:

ResultSet.getString truncating the column value of Sybase

Hi ,

I have a column of varchar(1500) in a table (in sybase 12.5) .
When ever I do rs.getString("columnName") , I get only 256 characters . I am not receving all the characters in the column .

Is this limitation of Sybase Driver ? (jconnect driver) ? . Is there any way I can get complete data ? Please advice ASAP .

Thanks for advice.
Raghav
0
raghava_dg
Asked:
raghava_dg
  • 7
  • 7
  • 6
  • +2
1 Solution
 
aozarovCommented:
0
 
raghava_dgAuthor Commented:
Ok . Then I need to convert the Clob to string is it ?
I will try this option .

Thanks
Raghava
0
 
neonlinesCommented:
Change the datatype of the field as "test" and then try

U can get only 256 chars if u declare the type as varchar
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CEHJCommented:
Try

StringReader value = new StringReader(resultSet.getCharacterStream("columnName"));
System.out.println(value.toString());
0
 
limaidealCommented:
I think Sybase has historical limit storing more than 255 chars in VARCHAR . For your case, I will recommend using CLOB.

From my experience, once the field type is set to TEXT(CLOB), with the newest driver, getString will work perfectly.

 
0
 
raghava_dgAuthor Commented:
aozarov  ,

CLOB is not supported in jconnect driver . So I can't use .

CEHJ ,

StringReader does not work . There is no constructer which takes Reader as argument .

I tried BufferedReader which takes Reader as constructer . But again same problem . I can not convert that back to string , if I tried to do BufferdReader.readLine()  I am getting 256 characters .

Guyz Any other ideas ?
0
 
aozarovCommented:
Are you sure that your problem is with reading it truncated and not writing it truncated?
Did you check the content of that column using some other (non jdbc) tool?
0
 
CEHJCommented:
>>There is no constructer which takes Reader as argument .

True. Try:


Reader in = resultSet.getCharacterStream("columnName");
StringBuffer sb = new StringBuffer(1500);
int buf = -1;
while((buf = in.read()) > -1) {
      sb.append((char)buf);
}
in.close();
System.out.println(sb);
0
 
raghava_dgAuthor Commented:
aozarov ,

Yes my problem is while reading . I have the data more than 256 char in the column .

CEHJ ,

I tried ur suggestion . But still no luck :( . Looks like even getCharacterStream is unable read more than 256 chars . I mean this might be a prob with Sybase JDBC drive (jconnect Version 12.5)

any advice on this appriciated .

0
 
aozarovCommented:
Do you mind to try a newer jconnection version -> http://www.sybase.com/detail?id=1009726 
That site also have a link to the jConnection discussion forum -> news://forums.sybase.com/sybase.public.jconnect
which I think will be a good place to find an answer to this question.
0
 
raghava_dgAuthor Commented:
Changing the driver at this point is not possible . I may have to look into some other option :(
0
 
aozarovCommented:
Did you try submitting your question to the forum mentioned above?
0
 
raghava_dgAuthor Commented:
i tried clicking on that link but its not opening . It asks for some exe to open the forum page . Are you able to access that ?  Please let me know .
0
 
aozarovCommented:
Yes, I am using Windows IE and it opens outlook with that specific news group.
You can access it thru here as well: http://groups-beta.google.com/group/sybase.public.jconnect
0
 
neonlinesCommented:
raghava_dg ,

see, I am working in Sybase only

u can not take more than 256 characters if u r not changing the Table field varchar(1500) as 'test'

test type will accept upto 2GB size of data and u can read the data by just

resultset.getString("TABLE_COLUMN_NAME").trim());

I given this solution already
0
 
neonlinesCommented:
Sorry

the type is not test

it should be  "text"

Just run the query as follows

alter table <tablenamer> modify <column name> text

it will change in ur table as follows:

Column_name     Type            Length      Prec Scale Nulls Default_name    Rule_name       Access_Rule_name               Identity
--------------- --------------- ----------- ---- ----- ----- --------------- --------------- ------------------------------ --------
TABLE_COLUMNS   text            16          (null(null)0     (null)          (null)          (null)                         0        
0
 
raghava_dgAuthor Commented:
yes neo .

You are correct . After much R&D even I found out that I should change the column to Text .
Thanks for the suggestion . I will grant you the points .

I have already an application where it uses getString() methods every where. If I change column type now , I am worrying that it may break some where else .
If you came accross this anytime , can you let me know potential problems in changing the coulmn type of a table of an already existing application ?


Thanks
Raghava
0
 
aozarovCommented:
So, you were able to save more then 256 characters (and I assume your verified that by reading the content somehow) but
without having the type of the column as TEXT the jdbc driver could not read more then 256 characters?
0
 
neonlinesCommented:
In Sybase, without having the type of the column as TEXT, the jdbc driver can not read more then 256 characters

If the type of the column is TEXT, u can save more than 256 characters and can retrieve too ...

aozarov :

>> and I assume your verified that by reading the content somehow

r u pointing out me??? If so, ur assumption is wrong and I faced the same problem in one of my project and I solved earlier in the same way

Raghava:

>>If I change column type now , I am worrying that it may break some where else .

Just changing the column type as TEXT and if u used getString to get the value it never give problem anywhere in ur program - I am sure about it :)
0
 
neonlinesCommented:

It's restriction with Sybase and not JDBC driver problem

Even, u can change such a restriction in Sybase too. For that, U should have Admin knowledge in Sybase to change those installation settings

Default sybase installation will not allow u to get more than 256 characters :)
0
 
aozarovCommented:
neonlines,
>> r u pointing out me???
Definetly not :-)
I asked raghava_dg if he managed to write successfuly (not truncated) and I think his answer was yes (see his third reply).
Thank you for making it clear.
0
 
neonlinesCommented:
thankz aozarov ;)
0
 
raghava_dgAuthor Commented:
Yes . I was able to store more than 256 characters bue retrival was the issue . By using TEXT we can solve this prob .

Thanks for every one for helping .
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 6
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now