As Robert indicated you can use the getType methods like this:

You have an object with a setName(String name) method and a setId(long id)
method, and a ResultSet named rs. The table that is pointed to by rs has a
first column that is type string and a second column that is type long.

obj.setName(rs.getString(1));
obj.setId(rs.getLong(2);

Reflection and ResultSetMetaData is great is you want to writer reuseable
code.... using a table's metadata you would get column names and types and
then using reflection you would match the column name  against a method in
your object and use the type of the column to set the data similar to the
example above.

-Rick

----- Original Message -----
From: "Robert Nicholson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 02, 2000 2:32 AM
Subject: Re: SQL results into an Object


> getType methods... or use reflection and ResultSetMetaData
>
> > -----Original Message-----
> > From: A mailing list about Java Server Pages specification and reference
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Raghunath Raman
> > Sent: Sunday, July 02, 2000 9:54 AM
> > To: [EMAIL PROTECTED]
> > Subject: SQL results into an Object
> >
> >
> > Hi ,
> >
> > I have a servlet that establishes a database connection , performs a
query
> > and retrieves a ResultSet.
> > Now I have an Object with fields into which I want to store the results
of
> > the Resultset.
> > I am a little lost with the commands.
> > Help will be greatly appreciated.
> > Thanks in advance,
> >
> > Regards
> >
> > ==================================================================
> > =========
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to