|
From: <tri...@tr...> - 2003-10-20 18:52:15
|
Juergen, > According to what I found out about MySQL, "last_insert_id" returns the last > used id on the same connection and is thus transactionally safe. Don't know > about HSQL, but I frankly don't mind for sample purposes. > HSQL has IDENTITY() which returns the last identity value for the connection - so the functionality is basically the same. We just have to make sure that we use the same connection - an sqlUpdate followed by an sqlQuery might not gurantee this. I have been thinking about creating a datasource that makes the same conection available for a series of database interactions (with supressClose turned on) - like a temporary SingleConnectionDataSource created from a pooled DataSource. What do you think of a MultipleUseConnectionDataSource that gets a DataSource passed in the constructor. This MultipleUseConnectionDataSource could then be passed in to several sqlUpdate or sqlQuery objects and deflect any attempts to close it during this sequence of database interaction. Finally we would call destroy() on the MultipleUseConnectionDataSource causing the connection to be returned to the pool. Thomas |