• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MS SQL BIGINT not accessible in java

 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Will do it.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic