Re: Synthesize support for Statement.getGeneratedKeys()?
От | Ken Johanson |
---|---|
Тема | Re: Synthesize support for Statement.getGeneratedKeys()? |
Дата | |
Msg-id | 45BAD630.8020209@kensystem.com обсуждение исходный текст |
Ответ на | Re: Synthesize support for Statement.getGeneratedKeys()? (Dave Cramer <pg@fastcrypt.com>) |
Список | 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
В списке pgsql-jdbc по дате отправления: