From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Zhipan Wang <wzhipan(at)soe(dot)ucsc(dot)edu> |
Cc: | pgsql-jdbc(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
Subject: | Re: [JDBC] ResultSet problem in JDBC |
Date: | 2010-12-02 06:44:33 |
Message-ID: | 4CF74051.7010102@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
On 02/12/10 13:14, Zhipan Wang wrote:
> 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();
You appear to be trying to implement a subquery client-side. Why not
just use:
PreparedStatement sql = c.prepareStatement(
"SELECT col1 FROM relation2 WHERE col0 IN "+
"(SELECT unnest(col0) from relation2_col1 where keyValue<500"
);
? It's hard to know whether the above is correct because you've failed
to provide your schema, but something along those lines seems to fit
your intent from the code above.
> I am using Eclipse, and there is no warning for this code.
No, Eclipse can't know the details of how every JDBC driver works.
> Can't a result set be used in another query? How do I correct it?
Either build an array with the contents of the resultset and pass that,
or avoid the weirdness by using a subquery directly.
--
System & Network Administrator
POST Newspapers
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2010-12-02 07:44:26 | Re: [GENERAL] How to recover a postgres installation from files |
Previous Message | Konstantin Izmailov | 2010-12-02 06:15:07 | number of rows returned by a query |
From | Date | Subject | |
---|---|---|---|
Next Message | marcofoc@libero.it | 2010-12-02 08:27:42 | Driver work slowly with new update of OpenJDK in Ubuntu.. |
Previous Message | marcofoc@libero.it | 2010-12-02 06:26:29 | Driver work slow with new upgrade of Openjdk in Ubuntu |