JDBC question: Which class is returned? - Mailing list pgsql-general

From Dr. Evil
Subject JDBC question: Which class is returned?
Date
Msg-id 20011012203002.11958.qmail@sidereal.kz
Whole thread Raw
Responses Re: JDBC question: Which class is returned?  (o2@trustcommerce.com)
Re: JDBC question: Which class is returned?  (Peter T Mount <peter@retep.org.uk>)
List pgsql-general
I am doing some queries using JDBC.  I use the ResultSet.getObject()
method to get the result object.  This works fine with SQL VARCHAR,
etc, but there is a big problem when I try it with an INT4.

For example:

Object obj = result.getObject(i);

It gets the object just fine but then I can't do anything with the
object.  I can't do this:

System.out.println("The result is: " + (String) obj);

or anything else.  I am guessing that the problem may be that it is
trying to return an integer type, which is not an object.  Any
sugestions on this?

One thing I think I could do is to try to detect the type using
MetaData.getResultType() or something, and then call
ResultSet.getInt() or whatever is appropriate.  Is this the best way
to do it?

Thanks

pgsql-general by date:

Previous
From: "Steve Wolfe"
Date:
Subject: Re: pop3 server and Postgresql
Next
From: Bruce Momjian
Date:
Subject: Re: Contents of greatbridge.com?