I am making an app in java that sends SQL queries. The user can propose a room that others can book. To propose a room, the user has to fill a form.
When the user fills the form and presses on the validate button, the app create an SQL query that insert the inputted information in a table proposedRoom
.
However each proposed room in my table has a primary key, proposedRoomId
which is an int
.
I am having trouble creating that primary key in Java before sending the Query to insert the room in the table.
What I tried to do is using the date to generate the corresponding integer, but if two people happen to propose a room at the same time it will cause error. I thought about hashing and changing the type of the key to String
but this seems complicated and may reduce my app performance.