aspose file tools*
The moose likes JDBC and the fly likes MS SQL BIGINT not accessible in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MS SQL BIGINT not accessible in java" Watch "MS SQL BIGINT not accessible in java" New topic
Author

MS SQL BIGINT not accessible in java

carina caoor
Ranch Hand

Joined: Jun 23, 2007
Posts: 300

Hi in my ms sql database i have a column with type bigint but in java program while trying to retrieve i have written
Long parentid=rs.getLong(1);
but its giving me the following error

java.sql.SQLException: The value supplied cannot be converted to BIGINT.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:570)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getLong(JtdsResultSet.java:661)
at java.lang.Thread.run(Unknown Source)

Can anyone please tell me how to access the bigint in java.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Will do it.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Are you sure the value you are reading is a number and not null? I'm surprised you can't use getLong() to read an integer since casting from int to long is straight forward.

You might want to consider debugging with getObject() than use instanceof command to determine the objects type.


My Blog: Down Home Country Coding with Scott Selikoff
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Ruquia,
I have never used the JTDS JDBC driver, but I imagine it must map database types to java classes.
I also assume it has associated documentation and that documentation should list the mappings between database types and java classes.

Method "getLong()" returns a "long" (primitive).
Method "getInt()" returns and "int" (primitive).

And Scott, how do you find the class of an Object using "instanceof"?
Wouldn't it be easier to just print the class name?
In other words:

Good Luck,
Avi.
 
wood burning stoves
 
subject: MS SQL BIGINT not accessible in java