Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MS SQL BIGINT not accessible in java

 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Will do it.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic