Using PreparedStatement, it would be like
Also overall you can do some code improvements. Whenever using
JDBC, ensure that Results, Statements and Connections are close()d in a finally block.
This ensures that all your JDBC resources are cleaned up even if there's an exception. The Resultset close()s are, strictly speaking, not necessary because statement.close would close them anyway; but it's good practice.>