jdbc

Topics related to jdbc:

Getting started with jdbc

Creating a database connection

PreparedStatement

A PreparedStatement declares the statement before it is executed, and allows for placeholders for parameters. This allows the statement to be prepared (and optimized) once on the server, and then reused with different sets of parameters.

The added benefit of the parameter placeholders, is that it provides protection against SQL injection. This is achieved either by sending the parameter values separately, or because the driver escapes values correctly as needed.

Statement batching

Statement batching allows a program to collect related statement, or in the case of prepared statements related parameter value sets, and send them to the database server as a single execute.

The benefits of statement batching can include improved performance. If and how these performance benefits are achieved depends on the driver and database support, but they include:

  • Sending all statements (or all values sets) in one command
  • Rewriting the statement(s) so they can be executed like one big statement

ResultSet

JDBC - Statement Injection

ResultSetMetaData