This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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: 860
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
 
 
subject: dynamic column names and it's values
 
Similar Threads
How to gray out one particular row in JTable
How can i add the 2 dimension matrix data and dispaly all the numbers.
MySQL table joining
get data from html tables and send it to controller/servlet
Creating a dynamic table