i have been trying to obtain the query that is being executed when running the executeBatch()
in the jdbc. When using, the executeQuery()
, i can obtain the correct query using originalSql
variable or sql
(implemented from the Statement
interface), but when i print the originalSql
variable for executeBatch()
it prints only the original sql as the name itself, with all the ?
marks.
String insertTableSQL = "INSERT INTO Employees"
+ "(id, age, first, last) VALUES"
+ "(?,?,?,?)";
PreparedStatement preparedStatement = conn.prepareStatement(insertTableSQL);
preparedStatement.setInt(1, 101);
preparedStatement.setInt(2, 67);
preparedStatement.setString(3, "niky");
preparedStatement.setString(4, "baa");
preparedStatement.addBatch();
int[] rs2 = preparedStatement.executeBatch();
I have been going through the code of the executeBatch()
as well. But still i am unable to find the exact location where it fill in the variables with input values. I am stuck in this for days.
Some help on this would be really appreciated. (If there is some method that i called by all three methods, executeQuery
, executeBatch
and executeUpdate
, it would make my work easier)