Search Postgresql Archives

ResultSet problem in JDBC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux