This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using ResultSet.getString( )

 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using the result set methods getInt(), getString() etc to get the values returned from the database do the database column types have to be of type number or varchar2 respectively?

Or, do the methods attempt to parse the value of the database column as a string (for the getString() method) or as a int (for the getInt() method)?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JDBC specification dictates the mappings between JDBC types and Java types. In addition, the JDBC driver can perform some type conversions if you ask for another type using getString() and so on. There's a table in the JDBC spec; an appendix, if I'm not mistaken.

- Peter
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!