7.1beta1 JDBC Nested cursor problem

From: Stu Coates <stu_coates(at)mail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: 7.1beta1 JDBC Nested cursor problem
Date: 2000-12-09 22:57:58
Message-ID: 380464233.976402678843.JavaMail.root@web597-mc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-novice

I think that I've found a little bug in the 7.1beta1 JDBC drivers. Attached is a simple test case which produces the problem on my setup (LinuxPPC 2000, on Apple PowerMac G3-400Mhz, 512MB). It would seem that the drivers and/or the DBMS has a problem with nested queries, even simple ones.

Here's the stacktrace:

Bad Long
at org.postgresql.jdbc2.ResultSet.getLong(ResultSet.java:284)
at Test.go(Test.java:35)
at Test.main(Test.java:15)

I'm using the 7.0.2 JDBC drivers against the 7.1beta1 backend and
everything seems to be working fine with those, just the new ones (7.1beta1) have this problem.

Stu.

-- create table/data script

create table mytest (mykey int8, foo varchar(20));

insert into mytest(mykey,foo) values (0,'stuff');
insert into mytest(mykey,foo) values (1,'stuff');
insert into mytest(mykey,foo) values (2,'stuff');
insert into mytest(mykey,foo) values (3,'stuff');
insert into mytest(mykey,foo) values (4,'stuff');
insert into mytest(mykey,foo) values (5,'stuff');
insert into mytest(mykey,foo) values (6,'stuff');
insert into mytest(mykey,foo) values (7,'stuff');
insert into mytest(mykey,foo) values (8,'stuff');
insert into mytest(mykey,foo) values (9,'stuff');

-- Test Program

import java.sql.*;
import java.io.*;

public class Test
{

public static void main(String [] args)
{
if(args.length!=3) {
System.err.println("Usage: <URL> <UID> <PWD>");
System.exit(1);
}
Test app=new Test();
try {
app.go(args[0],args[1],args[2]);
}
catch(Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
}
}

private void go(String url,String uid,String pwd) throws Exception
{
Class.forName("org.postgresql.Driver");
Connection connection=DriverManager.getConnection(url,uid,pwd);
connection.setAutoCommit(false);

PreparedStatement s=connection.prepareStatement("select mykey from mytest");

ResultSet rs=s.executeQuery();

while(rs.next()) {
PreparedStatement s2=connection.prepareStatement("select * from mytest where mykey=?");
s2.setLong(1,rs.getLong(1));
ResultSet rs2=s2.executeQuery();
while(rs2.next()) {
System.out.println(rs2.getLong(1) + " " + rs2.getString(2));
}
rs2.close();
s.close();
}

rs.close();
s.close();

connection.commit();
connection.close();
}

}
--
Stu Coates
Chelmsford, England U.K.
ICQ:146628
http://www.stucoates.com/

______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nabil Sayegh 2000-12-10 02:04:30 Re: [BUGS] 7.1beta1 JDBC Nested cursor problem
Previous Message Stu Coates 2000-12-09 18:42:19 7.1beta1 JDBC bug?

Browse pgsql-novice by date

  From Date Subject
Next Message Steve Waldman 2000-12-09 23:10:01 Re: Loading jdbc6.5-1.2.jar via forName()
Previous Message Wayne Johnson 2000-12-09 22:51:45 Loading jdbc6.5-1.2.jar via forName()