How can I determine that particular query will change the state of DB?
I use JDBC. Should I use parsing searching for key words like INSERT, DELETE or there are some other ways?
How can I determine that particular query will change the state of DB? I
Share
One way:
There would be variations. Explore the Statement API to get a feel for your options.
Edit: Ensure autocommit is off, or transactionality is out the window!
More edit: As pointed out by commenters, this isn’t a scalable solution. For scalability, transactions have to be kept short, and you don’t want to have user think time during an open transaction. If there will be multiple users, find a way to do this that doesn’t involve holding a transaction open, perhaps with some creative use of statement caching and rollbacks/commits. For better advice, explain more about your requirements.