I'm currently planning out a Java server that is running a thread pool that accepts client connections that will require that a database read/update occurs.
What about the case of multiple reads/writes on a single row? How should I manage this? Should I create a queue in Java or can MySQL handle this kind of stuff?
E.g. I plan on using transactions where I will use the following to lock a row:
Select <columns> from <table> where <condition> FOR UPDATE;
Question: What if another thread comes in and wants to update the same row before the first commits? Will the query fail or will MySQL hold it for a while and wait for the first lock to be release?
My current solution: I'm thinking a way to do it could be to create a static queue/pipe of all queries so that only one is fed to the DB at a time. This is obviously a bottleneck and general bad idea?
Also, are there any Java frameworks that handle this kind of thing and MySQL connections in general? Thanks.
EDIT: I am planning on using a threadpool so all queries will be coming from seperate connections.