File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "MS SQL BIGINT not accessible in java" Watch "MS SQL BIGINT not accessible in java" New topic

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(
at net.sourceforge.jtds.jdbc.JtdsResultSet.getLong(
at Source)

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

Joined: Apr 14, 2004
Posts: 10336

Will do it.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

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.

[OCA 8 Book] [Blog]
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

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,
I agree. Here's the link:
subject: MS SQL BIGINT not accessible in java
jQuery in Action, 3rd edition