S
shya
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!
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!