I am developing an application using Java and I have an Oracle database. To store data I am using JDBC. In Oracle database, there is nothing like a Auto Increment. So I have used triggers to get the lastest primary key.
Currently the application has been implemented and I get the saved primary key back. This happens when the connection.setAutoCommit(true) is set. What I would like to know if I set the connection.setAutoCommit(false) is it possible to get the primary key?
The reason why I ask this is because I am facing some concurrency issue with multiple threads where one thread saves the data and and another thread can pick up the saved record. I don't want this to happen. I want the code to be sequentially completed before the other thread views the data. So, I tried to investigate JDBC row lock but nothing like this exists.
This primary key is required for an input into another method within the same Thread.