pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ken Johanson <pg-user@kensystem.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Date: Fri, 26 Jan 2007 21:33:52 -0700
Message-ID: <45BAD630.8020209@kensystem.com> (raw)
In-Reply-To: <BF964F23-468F-4E84-81F2-BEA50E473673@fastcrypt.com>
References: <4580E681.3080106@kensystem.com>
	<45B9A9D6.2080100@kensystem.com>
	<BF964F23-468F-4E84-81F2-BEA50E473673@fastcrypt.com>

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





view thread (50+ messages)  latest in thread

Message-ID: <45BAD630.8020209@kensystem.com>
Permalink:  ../45BAD630.8020209@kensystem.com/
Also on:    postgresql.org/message-id/45BAD630.8020209@kensystem.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg-user@kensystem.com, pg@fastcrypt.com
  Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
  In-Reply-To: <45BAD630.8020209@kensystem.com>
  References: <4580E681.3080106@kensystem.com> <45B9A9D6.2080100@kensystem.com> <BF964F23-468F-4E84-81F2-BEA50E473673@fastcrypt.com> <45BAD630.8020209@kensystem.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox