Re: Synthesize support for Statement.getGeneratedKeys()?

From: Ken Johanson <pg-user(at)kensystem(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Date: 2007-01-27 04:33:52
Message-ID: 45BAD630.8020209@kensystem.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Dave Cramer wrote:
> Ken,
>
> Do you have a test case ? What do the server logs show ?
>

Hi Dave,

My test case is:

String url = "jdbc:postgresql://127.0.0.1:5432/test?stringtype=unspecified";
String clz = "org.postgresql.Driver";
String dml = "insert into contact (rowid,logonname) values (DEFAULT,'bar')";
String[] keys = {"rowid"};
Connection con = DriverManager.getConnection(url, "user", "pass");
Statement stmt = con.createStatement();
int affected = stmt.executeUpdate(dml, keys);
ResultSet rs = stmt.getGeneratedKeys();
if (rs.next())
out.println(rs.getObject(1));
else
out.println("NO ROWS, INSERTED "+affected);

A ResultSet is returned but has no rows. The insert does succeed and a
sequence generated key increments in the 'rowid' column.

I think the issue is just that my code is not calling through the
correct private methods that would populate a result.

Also I noticed that so far my mods have not implemented
Stmt.NO_GENERATED_KEYS & RETURN_GENERATED_KEYS;

On a related note, do you know how I could call though a Stream method
instead of the String/Charsequence execs?

Thanks,
Ken

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-01-27 04:50:56 Re: Synthesize support for Statement.getGeneratedKeys()?
Previous Message Tom Lane 2007-01-26 16:43:26 Re: wrong parsing of "select version();"