Java:sql using result set type of class?

Hi
What way should I write the java code to do sql when the out come should only be a bunch of fields to be displayed in a JSF type  JSP? As opposed to a List maybe or as opposed to an ArrayList. Can I get some type example?
Thank you
coolgemAsked:
Who is Participating?
 
InteractiveMindCommented:
Perform the query, the result will be returned as a ResultSet instance; call this instance's getArray() method, and specify the required column as a parameter (either as an index—int, or column name—String).


// shove this stuff inside a try{} scope.

Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ;
Connection conn = DriverManager.getConnection( "jdbc:odbc:MyDataBase", "", "" ) ; // db, username, password

Statement st = conn.createStatement() ;

ResultSet rec = st.executeQuery( "SELECT column_name FROM table WHERE something_is_true" ) ;

String [] rows = (String [] ) rec.getArray( 1 ) ;  // 1 = the first column

st.close() ;



You now have the results in a String array, caleld 'rows'.
0
 
InteractiveMindCommented:
Am not entirely clear; could you elaborate?
0
 
coolgemAuthor Commented:
Can I get an example of a java class that does sql and places the result into some setters?
Thank you
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
InteractiveMindCommented:
Will the result be for just a single column, or for multiple?
Can you also expand a little on the "setters"; a particular data type?
0
 
coolgemAuthor Commented:
single column ... string fields and a text field.
thank you
0
 
coolgemAuthor Commented:
thank you very much have a great weekend!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.