You can invoke the execute methods on the same PreparedStatement object any number of times and the SQL is only compiled once. In your example you would not be able to change the values of name or emp as they would have been compiled into the statement when the PreparedStatement was created. You can create a variable in a statement by using a ?, then using PreparedStatement.setXXX() to change the value between executions. Read more about PreparedStatement in the
Java Tutorial