pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Zhipan Wang <wzhipan@soe.ucsc.edu>
To: pgsql-jdbc@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: ResultSet problem in JDBC
Date: Wed, 1 Dec 2010 21:14:46 -0800 (PST)
Message-ID: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu> (raw)
In-Reply-To: <1503640621.914211291266514731.JavaMail.root@mail-01.cse.ucsc.edu>


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? 

view thread (2+ messages)  latest in thread

Message-ID: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu>
Permalink:  ../3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu/
Also on:    postgresql.org/message-id/3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: wzhipan@soe.ucsc.edu, pgsql-general@postgresql.org
  Subject: Re: ResultSet problem in JDBC
  In-Reply-To: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu>
  References: <1503640621.914211291266514731.JavaMail.root@mail-01.cse.ucsc.edu> <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox