You could execute the quesry in a seperate
Thread, and after a given amount of time, call the cancel() method on the statement object (the original Thread would have to have a reference to it. All in all it's simple, but not for a beginning
JDBC or Thread programmer.
You's also want to make this a
pattern in your development, and implement it in a generic way - so it's not a simple solution.
I think that the bigger problem is people having direct access to run these types of locking queries on the database!