Unix Technical Forum

Problem with JDBC version 8.0/1 vs. 7.4

This is a discussion on Problem with JDBC version 8.0/1 vs. 7.4 within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, I'm trying to run the SQL statement found below. Meaning, if I have a String sql set to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:31 AM
Bob Fischer
 
Posts: n/a
Default Problem with JDBC version 8.0/1 vs. 7.4

Hello,

I'm trying to run the SQL statement found below. Meaning, if I have a
String sql set to the big hunk of text below the '----', I then call
ResultSet rs = statement.executeQuery(sql);

When I use the JDBC Driver v7.4, everything works just fine (and it
returns some rows). But when I use JDBC Driver v8.0 or v8.1, I get the
following Exception:

org.postgresql.util.PSQLException: No results were returned by the
query.
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execut eQuery(AbstractJdbc2Statement.java:240)


Does anyone know what is causing this problem or how to fix it? For now
I'm sticking with the 7.4 driver.

Thanks,
-- Bob

-----------------------
create temporary table _ids (entityid int); delete from _ids;
delete from _ids;
insert into _ids (entityid) select entityid from persons where
firstname ilike '%kent%' or lastname ilike '%kent%' union select
entityid from organizations where name ilike '%kent%';
(select o.entityid, 'organizations' as relation, name as name ,
o.entityid = o.primaryentityid as isprimary from organizations o, _ids
where o.entityid = _ids.entityid
union
select p.entityid, 'persons' as relation, (case when lastname is null
then '' else lastname || ', ' end || case when firstname is null then ''
else firstname || ' ' end || case when middlename is null then '' else
middlename end) as name , p.entityid = p.primaryentityid as isprimary
from persons p, _ids where p.entityid = _ids.entityid) order by
relation, name;
drop table _ids



---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:31 AM
Kris Jurka
 
Posts: n/a
Default Re: Problem with JDBC version 8.0/1 vs. 7.4



On Sun, 14 Jan 2007, Bob Fischer wrote:

> I'm trying to run the SQL statement found below. Meaning, if I have a
> String sql set to the big hunk of text below the '----', I then call
> ResultSet rs = statement.executeQuery(sql);
>
> When I use the JDBC Driver v7.4, everything works just fine (and it
> returns some rows). But when I use JDBC Driver v8.0 or v8.1, I get the
> following Exception:
>
> org.postgresql.util.PSQLException: No results were returned by the
> query.
>


Newer JDBC drivers return all of the results from a multi statement query
execution instead of just the last one. You should call it like so:

stmt.execute("SELECT 1; UPDATE t SET a=1; SELECT 2;");
ResultSet rs = stmt.getResultSet();
stmt.getMoreResults();
int count = stmt.getUpdateCount();
rs = stmt.getResultSet();

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com