Java applications that hold some or all classes in the database have significant advantages over traditional SQL stored procedures. At an introductory level, however, it may be helpful to use the parallels with SQL stored procedures to demonstrate the capabilities of JDBC. In the following examples, you write Java classes that insert a row into the Departments table.
As with other interfaces, SQL statements in JDBC can be either static or dynamic. Static SQL statements are constructed in the Java application and sent to the database. The database server parses the statement, selects an execution plan, and executes the statement. Together, parsing and selecting an execution plan are referred to as preparing the statement.
If a similar statement has to be executed many times (many inserts into one table, for example), there can be significant overhead in static SQL because the preparation step has to be executed each time.
In contrast, a dynamic SQL statement contains place holders. The statement, prepared once using these place holders, can be executed many times without the additional expense of preparing. Dynamic SQL is discussed in How to use prepared statements for more efficient access.
Preparing for the JDBC examples
Inserts, updates, and deletes using JDBC
Using static INSERT and DELETE statements from JDBC
How to use prepared statements for more efficient access
Using prepared INSERT and DELETE statements from JDBC
JDBC batch methods
How to return result sets from Java
Returning result sets from JDBC
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0|