|
Dieses Gerät hat auch andere Anweisungen:
Anleitung Zusammenfassung
Connection.createStatement and Connection.PreparedStatement are used to create these objects. In some
instances, NonStopTM Server for Java might need to choose an alternative result set type for a result set at Statement or
PreparedStatement execution time.
Concurrency Types and Result Sets
An application can choose from two different concurrency types for a result set: read-only and updatable.
A result set that uses read-only concurrency does not allow updates of its contents. All result sets prior to JDBC 2.0 are
read-only; this means the result set type is CONCUR_READONLY.
An updatable result set allows rows to be updated, deleted, and inserted. A result set is updatable if its concurrency type is
CONCUR_UPDATABLE.
ResultSet.updatexxx() methods are used to modify the value of an individual column in the current row, but do not
update the underlying database. When the ResultSet.updateRow() method is called, the data base is updated. The
JDBC driver discards updates if the application moves the cursor from the current row before calling updateRow(). In
addition, an application can call the ResultSet.cancelRowUpdates() method to explicitly cancel the updates that
have been made to a row before updateRow() is called.
To delete a row, an application moves the cursor to the row to be deleted and invokes the ResultSet.deleteRow()
method.
The JDBC 2.0 API defines the concept of an insert row that is associated with each result set and is used as a staging area for
creating the contents of a new row before it is inserted into the result set itself. The ResultSet.moveToInsertRow()
method is used to position the result set's cursor on the insert row. The ResultSet.updatexxx() and
ResultSet.getxxx() methods are used to update and retrieve individual column values from the insert row. The content
of the insert row is undefined immediately after calling ResultSet.moveToInsertRow(). Calling
ResultSet.updatexxx() while on the insert row does not update the underlying database or the result set. After all of
the column values are set in the insert row, ResultSet.insertRow() is called to update the result set and the database
simultaneously.
The JDBC 2.0 API does not specify how a JDBC driver provides an updatable result set. The API does suggest that an
optimistic concurrency control scheme can be used to prohibit updates from conflicting with those made by other applications.
Optimistic concurrency control implementations typically compare rows either by value or by a version number to determine if
any update conflict has occurred. NonStopTM Server for Java compares rows by value.
As with scrollable result sets, NonStopTM Server for Java sometimes might need to choose an alternate concurrency type for a
result set at Statement execution time. Generally, queries that meet the following criteria will produce an updatable result
set:
The query references only a single table in the database.
q
The query does not contain any join operations.
q
The query selects the primary key of the table it references.
q
In addition, a SQL query should also satisfy the following criteria if inserts are to be performed.
The query selects all of the nonnullable columns in the underlying table.
q
The query selects all columns that do not have a default value.
q
Batch Updates
The batch update facility allows a Statement object to submit a set of heterogeneous update commands together as a single
unit, or batch, to the underlying DBMS. A Statement object has the ability to monitor a list of commands that can be
submitted together for execution. When a statement is created, its associated command list is empty. The
Statement.addBatch() method adds an element to the calling statement's list of commands. A SQLException is
thrown when Statement.executeBatch() is called if the batch contains a command that attempts to return a result set.
The JDBC 2.0 documentation states that batch updates result in a performance improvement. Because SQL/MP does not
support batch updates, it is unlikely that a performance improvement will occur; nevertheless, the batch update capability is
provided.
The batch update facility is used with prepared statements to associate multiple sets of input parameter values with a single
...Dieses Handbuch ist für folgende Modelle:
PC Desktops - HP NonStop L-Series (498.19 kb)