Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2004

Tip: Looking for answers? Try searching our database.

SQLException while using next()-method in scrolling a ResultSet

Thread view: 
David Thijs - 10 Dec 2003 08:12 GMT
Hi,

I'm having a strange problem, each time I want to go through a
ResultSet by using :

   query = "select * from TBL_test_ulrik";
   try{
     rs = s.executeQuery(query);
     int i=0;
     while (rs.next()){
       System.out.println(rs.getString(1));
       
     }
   }
   catch (SQLException se){
     se.printStackTrace();
   }

I get the following error-message

java.sql.SQLException: [interclient][interbase]arithmetic exception,
numeric overflow, or string truncation
[interclient][interbase]Cannot transliterate character between
character sets

    at interbase.interclient.ResultSet.remote_FETCH_ROWS(Unknown Source)

    at interbase.interclient.ResultSet.getNextCursorPosition(Unknown
Source)

    at interbase.interclient.ResultSet.next(Unknown Source)

    at tree_db.DBConnection_Tris.roepWaardenOp(DBConnection_Tris.java:93)

    at tree_db.ReadTextFile_Tris.zoekinDB(ReadTextFile_Tris.java:155)

    at tree_db.ReadTextFile_Tris.maakKeuze(ReadTextFile_Tris.java:33)

    at tree_db.ReadTextFile_Tris.<init>(ReadTextFile_Tris.java:14)

    at tree_db.ReadTextFile_Tris.main(ReadTextFile_Tris.java:159)

What is strange is that the same structure for executing another query
on another table doesn't give me this error-message.
Is there someone who can help me ??

Greetings,

David
Andree Große - 10 Dec 2003 16:24 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>       while (rs.next()){
>         System.out.println(rs.getString(1));

Use rs.getObject(1) instead.

HTH A.G.
Thijs David - 10 Dec 2003 18:18 GMT
rs.getObject(1) , doesn't work either :o((

David

> > Hi,
> >
[quoted text clipped - 11 lines]
>
> HTH A.G.
Joe Weinstein - 10 Dec 2003 16:25 GMT
> Hi,
>
> I'm having a strange problem, each time I want to go through a
> ResultSet by using :

Hi. There's nothing wrong with your JDBC code. The exception
is a problem between the jdbc driver and DBMS, and it seems
to do with the character set the client expects, and the character
set in the DBMS. Check your driver, DBMS and JVM information
about the character set in effect.
Joe Weinstein at BEA

>     query = "select * from TBL_test_ulrik";
>     try{
[quoted text clipped - 40 lines]
>
> David
Thijs David - 10 Dec 2003 18:17 GMT
Hi,

Thx for the advice, but I still am questioning myself, why it works with one
table (with exactly the same column types) and not with the other one ???

David

> > Hi,
> >
[quoted text clipped - 52 lines]
> >
> > David
Joe Weinstein - 10 Dec 2003 18:38 GMT
> Hi,
>
> Thx for the advice, but I still am questioning myself, why it works with one
> table (with exactly the same column types) and not with the other one ???
>
> David

Actually, Andree may have an important point. If the DBMS's table has
data that is not appropriately converted to a String, then your getString()
call is the problem. DOing getObject() and processing the object according
to it's type should always put the problem/control into your hands.
Joe

>>>Hi,
>>>
[quoted text clipped - 52 lines]
>>>
>>>David
Thijs David - 10 Dec 2003 18:27 GMT
Hi,

It's even so that I can call three columns out of 4 without any kind of a
problem these three columns are all of type integer in the DBMS.
The fourth column is of type varchar(150) and gives me all the problems,
allthough another column in another table with exactly the same type doesn't
pose any problems.

David

> > Hi,
> >
[quoted text clipped - 52 lines]
> >
> > David
Joe Weinstein - 10 Dec 2003 18:41 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> allthough another column in another table with exactly the same type doesn't
> pose any problems.

Ok. Varchar columns should certainly be retrievable by getString(),
so the issue is the characters stored, and the DBMS/driver failing
to convert those particular varchars to a string using the character set
of the client JVM. getObject() would typically know the data were varchars,
so it would typically create a String as the Object to return, so the
problem would not be avoided that way.
   Try getBytes() and see what the JVM does when trying to create
a string from the raw bytes.

Joe Weinstein at BEA

>>>Hi,
>>>
[quoted text clipped - 52 lines]
>>>
>>>David
Thijs David - 10 Dec 2003 18:42 GMT
Hi Joe,

Thx for your tip...
Andree probably has a good tip also, and I'm going to apply the getObject()
so that afterwards I'll be converting it into the exact type (more control
on my hand indeed).
Your tip concerning different about different charactersets made me wonder,
so I began testing different charactersets in the DBMS and actually,
UNICODE-FSS seems to work fine for the moment, hopefully it stays that
way...
Anyway, thx a lot...

David

> > Hi,
> >
[quoted text clipped - 52 lines]
> >
> > David
redv - 14 Feb 2004 12:22 GMT
Attention: the exception is throwed while we using the next()-method not using the getXXX()-method.

You can specify the column's character sets, such as GBK or GB2312 if you will store Chinese characters in this column, instead of NONE.

So you should re-create your database as the alter sql command do not support to change the character sets.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.