Building and executing JDBC queries is straightforward. The general process is to construct a Java Statement object (either statically or dynamically), execute it, and then iterate through the query results.
These are the only aspects of building queries that require a bit of thought:
Choosing the right kind of statement to construct
Distinguishing retrievals of data from updates to data
We'll see more detail about both of these issues shortly.
To construct a JDBC statement, we simply need to obtain a Statement object from a Connection object and then execute that statement using a valid SQL query. Say we want to query the first and last names of all employees in our database. For the sake of example, ...