jdbc arbitrary attributes



hi there!
I'm new to jdbc programming, and I can't find an answer for my problem.
Take for example this bunch of code:

protected void executeQuery( Connection con, String sqlStatement )
     throws Exception {

    try {
      Statement s = con.createStatement ( );
      ResultSet rs = s.executeQuery( sqlStatement );

      while ( rs.next ( ) ) {
        String id = ( rs.getObject ("id").toString() );
        String text = ( rs.getObject ("text").toString() );

        System.out.println ( "found record : " + id + " " + text );
      }

      rs.close ( );

    } catch ( SQLException e ) {
      System.out.println ( "Error executing sql statement" );
      throw ( e );
    }
}

well, in this query, it retrives the attributes "id" and "text" from the result set. That's ok. But, how could I retrive _all_ the attributes in a particular ResultSet without know them before?
For instance, my executeQuery method should be perform query like:


SELECT NAME, SURNAME
FROM TABLE1
WHERE etc...

or

SELECT *
FROM TABLE1
WHERe ...

can you help me?
thanks!

--

Shya
.



Relevant Pages

  • new to jdbc!
    ... protected void executeQuery(Connection con, String sqlStatement) ... throws Exception { ...
    (comp.lang.java.programmer)
  • Re: new to jdbc!
    ... protected void executeQuery(Connection con, String sqlStatement) ... throws Exception { ... int columnCount = rsmd.getColumnCount; .... ...
    (comp.lang.java.programmer)
  • Re: SQLExpress
    ... Connection con = DriverManager.getConnection( ... System.err.println("Got an exception! ... Is /K0322608 the nameof the host where the SQL database lives? ...
    (comp.lang.java.databases)
  • Re: Accessing context parameters from web.xml in java class
    ... Connection con = DriverManager.getConnection(conn_url, db_username, ... You absolutely must not omit exception handling in production code. ... a bad example to post Usenet code that violates these precepts unless you ...
    (comp.lang.java.programmer)
  • Re: Accessing context parameters from web.xml in java class
    ... public class DBUtils { ... Connection con = DriverManager.getConnection(conn_url, db_username, ... You absolutely must not omit exception handling in production code. ...
    (comp.lang.java.programmer)