Hi,
My java application calls some stored procedures and some of these procedures use LAST_INSERT_ID(). The application creates a connection at startup and destroys the connection when it shuts down.
I was thinking, however, that if it were multi-threaded and some of the stored procedures were being called almost simultaneously, then the last_insert_id() could retrieve the wrong value as both calls to the stored procedure would be on the same connection.
Is this right? And if so, how do people get around this? I'm hesitant to using a new connection everytime i want to interact with the database as I believe creating connections are far more expensive and slower than anything else with regards to interacting with the database.
Thanks!
My java application calls some stored procedures and some of these procedures use LAST_INSERT_ID(). The application creates a connection at startup and destroys the connection when it shuts down.
I was thinking, however, that if it were multi-threaded and some of the stored procedures were being called almost simultaneously, then the last_insert_id() could retrieve the wrong value as both calls to the stored procedure would be on the same connection.
Is this right? And if so, how do people get around this? I'm hesitant to using a new connection everytime i want to interact with the database as I believe creating connections are far more expensive and slower than anything else with regards to interacting with the database.
Thanks!