Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

returning value of ResultSetMetaData.getColumnType(int column)

 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can anybody tell me what will ResultSetMetaData.getColumnType(int column)
returns. It returns an integer, what is that integer. For eg. for column type Varchar2 it returned 12.
Thanks
Neha
 
Junilu Lacar
Bartender
Posts: 7568
52
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not rely on the actual int value but on the constants defined in java.sql.Types
[This message has been edited by JUNILU LACAR (edited August 23, 2001).]
 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junilu,
Could you explain further, I didn't understand what is the interger type of column type. I mean if it is string what it should return, if it is 'Date' type what should this method return.
Thanks
Neha
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the static constants that are defined in the class java.sql.Types.
One of these static integer constants is what is returned by getColumnType(int c).
hope this clarifies...
 
John Kilbourne
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivor Horton's chapter of his Beginning Java book, on JDBC is on the web, I think at the Sun site. He explains this very well. It's in PDF, or I would paste an excerpt here.
"The Types class in the java.sql package defines public fields of type int that identify the SQL types, and the names of these class data memebers are the same as the SQL types they represent -- such as CHAR,VARCHAR, DOUBLE..."

------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic