I have a query script that is an update sql query having regex_replace to update a specific string to the desired string in db. I have used prepared statement of Java to run this query in my script. Something like this:
String SQL="UPDATE query where created >= ? and created < ?";
PreparedStatement stmt = conn.prepareStatement(SQL);
stmt.setDate(1, new java.sql.Date(datecreated.getTime()));
stmt.setDate(2, new java.sql.Date(datecreatedTill.getTime()));
System.out.println("Script start time: "+ new java.util.Date());
result = stmt.executeBatch();
So, I have the following questions now:
1. Is it the correct way to use prepared statement to optimize the update I intend to use?
2. Also, I read that preparedstatement basically combines all the queries into one or optimize multiple sql queries being passed to the db. So, i don't know how this regex_replce update query will get optimised as it will be just one sql query running on multiple records.
3. Please suggest if this is not a correct approach then if there is a better approach I can use
What I have tried:
I have tried to look over internet but optimising update with regex_replace is nowhere on the internet.