I’m working with PreparedStatement with MySQL Server.
example:
String myQuery = "select id from user where name = ?";
PreparedStatement stmt = sqlConnection.prepareStatement(myQuery);
stmt.setString(1, "test");
stmt.executeQUery();
ResultSet rs = stmt.getResultSet();
How can I receive the full SQL query that is about to be executed on the MySQL Server?
It’s not mandated by the JDBC spec, but several JDBC drivers let the
toStringof aPreparedStatementreturn sort-of the query that will be run, and MySQL’s Connector/J happens to have this behavior (or at least it did a few years ago).