• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic column names and it's values

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider I have a table Name, It's dynamic table. Column Names or it's data type is changable.

It contains lot of column names with different data type. How can I fetch all the rows in the Database.

if first column field type is date, then I have to use

rs.getDate(1); //

if it is String

rs.getString(1);

But in my situation,

It's dynamic table. Column Names or it's data type is changable.

Then How can I fetch all the rows? Please explain.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34205
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward,
You can always fetch all columns as Strings is you don't need them formatted in a certain way. The alternative is to use the result set meta data API to determine the specific data types.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getObject method returns the data and doesn't convert it to a String. This is useful should you ever need to manipulate the data in its original form via casting.

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#getObject(int)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic