commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: [DbUtils] Returning the newly-generated primary key after an insert
Date Sun, 29 Jan 2012 16:14:03 GMT
Hi Bill,

we could manage at least the generated keys, using
Statement#getGeneratedKeys()[1], requiring a non null
ResultSetHandler.
To not break APIs backward compatibility, that could be a new set of APIs...

WDYT?
best,
-Simo

[1] http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getGeneratedKeys()

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/



On Sun, Jan 29, 2012 at 5:05 PM, William Speirs <wspeirs@apache.org> wrote:
> That is a question more specific to the database you're using, than
> DBUtils. For some databases this means writing a stored procedure which
> performs the insert, and then a special select to get the primary key. You
> can of course use DBUtils to call this stored proc and read the primary key.
>
> Hope this helps...
>
> Bill-
>
> On Sun, Jan 29, 2012 at 9:44 AM, Moandji Ezana <mwanji@gmail.com> wrote:
>
>> Is it possible with the current API to do an insert and get back the
>> generated primary key, rather than the number of affected rows?
>>
>> Best regards,
>>
>> Moandji
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message