shows a program,
takes a list of class names and uses the Java Reflection API to build
a database of those classes, the packages they belong to, and all
methods and fields defined by the classes. Example 18-4 shows a program that
uses the database created by this example.
MakeAPIDB uses the
CREATE TABLE statement to add
three tables, named
member, to the database. The program then
inserts data into those tables using
INTO statements. The program uses the same
INTO statements repeatedly, as it iterates
though the list of class names. In this type of situation, you can
often increase the efficiency of your insertions if you use
PreparedStatement objects to execute the
A prepared statement is essentially a blueprint for the statements you need to execute. When you send a SQL statement to the database, the database interprets the SQL and creates a template for executing the statement. If you are sending the same SQL statement repeatedly, only with different input parameters, the database still has to interpret the SQL each time. On database platforms that support prepared statements, you can eliminate this inefficiency by sending a prepared statement to the database before you actually make any calls to the database. The database interprets the prepared statement and creates its template just once. Then, when you execute the prepared statement repeatedly with different input parameters, ...