From: | Zhipan Wang <wzhipan(at)soe(dot)ucsc(dot)edu> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | ResultSet problem in JDBC |
Date: | 2010-12-02 05:14:46 |
Message-ID: | 3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
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?
From | Date | Subject | |
---|---|---|---|
Next Message | Konstantin Izmailov | 2010-12-02 06:02:44 | Re: Does Postgres support bookmarks (tuples ids)? |
Previous Message | Adrian Klaver | 2010-12-02 03:44:30 | Re: Cannot start Postgres- FATAL: invalid cache id: 19 |
From | Date | Subject | |
---|---|---|---|
Next Message | Radosław Smogura | 2010-12-02 05:33:08 | Re: Storing timestamps in text format |
Previous Message | Craig Ringer | 2010-12-02 01:02:16 | Re: [HACKERS] Improved JDBC driver part 2 |