JDBC question: Which class is returned?

From: "Dr(dot) Evil" <drevil(at)sidereal(dot)kz>
To: pgsql-general(at)postgresql(dot)org
Subject: JDBC question: Which class is returned?
Date: 2001-10-12 20:30:02
Message-ID: 20011012203002.11958.qmail@sidereal.kz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc


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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Palle Girgensohn 2001-10-12 20:40:45 Re: Unixtime from timedate?
Previous Message Marc SCHAEFER 2001-10-12 20:17:19 Re: pop3 server and Postgresql

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oleg Lebedev 2001-10-12 22:28:56 Function calls via JDBC
Previous Message Mihai Gheorghiu 2001-10-12 18:57:08 Error messages