*
The moose likes JDBC and the fly likes dynamic column names and it's values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "dynamic column names and it Watch "dynamic column names and it New topic
Author

dynamic column names and it's values

Edward Durai
Ranch Hand

Joined: Oct 09, 2004
Posts: 223
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.


Thank You<br />Edward
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
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)



http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamic column names and it's values