Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D0DDF133740B for ; Thu, 2 Dec 2010 01:14:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 69138-04; Thu, 2 Dec 2010 05:14:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-01.cse.ucsc.edu (mail-01.cse.ucsc.edu [128.114.48.32]) by mail.postgresql.org (Postfix) with ESMTP id 03B8F1337B8B; Thu, 2 Dec 2010 01:14:48 -0400 (AST) Received: from mail-01.cse.ucsc.edu (mail-01.cse.ucsc.edu [128.114.48.32]) by mail-01.cse.ucsc.edu (Postfix) with ESMTP id 98C221009B90; Wed, 1 Dec 2010 21:14:46 -0800 (PST) Date: Wed, 1 Dec 2010 21:14:46 -0800 (PST) From: Zhipan Wang To: pgsql-jdbc@postgresql.org Cc: pgsql-general@postgresql.org Message-ID: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu> In-Reply-To: <1503640621.914211291266514731.JavaMail.root@mail-01.cse.ucsc.edu> Subject: ResultSet problem in JDBC MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14709_917667117.1291266886471" X-Originating-IP: [76.126.57.100] X-Mailer: Zimbra 5.0.20_GA_3127.RHEL5_64 (ZimbraWebClient - FF3.0 (Win)/5.0.20_GA_3127.RHEL5_64) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/52 X-Sequence-Number: 170343 ------=_Part_14709_917667117.1291266886471 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi all, I am writing a Java program using postgres. When I run my program, I got the following error message: Exception in thread "main" org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.jdbc4.Jdbc4ResultSet. Use setObject() with an explicit Types value to specify the type to use. at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1772) at org.postgresql.jdbc3g.AbstractJdbc3gStatement.setObject(AbstractJdbc3gStatement.java:37) at org.postgresql.jdbc4.AbstractJdbc4Statement.setObject(AbstractJdbc4Statement.java:46) at Cracking.testMethod(Cracking.java:619) at GetConnection.main(GetConnection.java:97) My code that caused this problem is: Statement st = c.createStatement(); ResultSet r = st.executeQuery("select unnest(col0) from relation2_col1 where keyValue<500"); PreparedStatement sql = c.prepareStatement( "SELECT col1 FROM relation2 WHERE col0 IN ?"); sql.setObject(1, r); ResultSet result = sql.executeQuery(); I am using Eclipse, and there is no warning for this code. Can't a result set be used in another query? How do I correct it? ------=_Part_14709_917667117.1291266886471 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: Times New Roman; font-size: 12pt; color: #000000'= >
Hi all,
I am writing a Java prog= ram using postgres. When I run my program, I got the following error messag= e:
Exception in thread "main" org.post= gresql.util.PSQLException: Can't infer the SQL type to use for
 an = instance of org.postgresql.jdbc4.Jdbc4ResultSet. Use setObject() with an ex= plicit Types value to specify the type to use.
    at org= .postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.j= ava:1772)
    at org.postgresql.jdbc3g.AbstractJdbc3gStat= ement.setObject(AbstractJdbc3gStatement.java:37)
    at o= rg.postgresql.jdbc4.AbstractJdbc4Statement.setObject(AbstractJdbc4Statement= .java:46)
    at Cracking.testMethod(Cracking.java:619)    at GetConnection.main(GetConnection.java:97)
= My code that caused this problem is:
= Statement st =3D c.createStatement();
ResultSet r =3D st.executeQuery("s= elect unnest(col0) from relation2_col1 where keyValue<500");
Prepared= Statement sql =3D c.prepareStatement( "SELECT col1 FROM relation2 WHERE col= 0 IN ?");
sql.setObject(1, r);
ResultSet result =3D sql.executeQuery(= );

I am using Eclipse, and there is no warning for this code. =
Can't a result set be used in another query? How do I correct it?
<= /div>
------=_Part_14709_917667117.1291266886471--