JDBC2.0 expansion API (4)

zhaozj2021-02-17  62

When a connection is involved in a distributed transaction, the following code is what you can't do (ConNeration Connection supports distributed transactions).

Con.commit (); or con?setautocommit (TRUE); for the usual Connection, the default is Auto-Commit mode. For Connection that supports distributed transactions, the default is not Auto-Commit mode. Note that even if the connection is supported, it can also be used without transaction. Regarding the restriction of the transaction boundary is only established with a distributed transaction.

When configuring DataSource supporting the connection pool, it involves configuring the ConnectionPoolDataSource object, which is the intermediate layer in the three-layer architecture to manage the connection pool. Similarly, when configuring support for distributed transactions, you need to configure XADataSource, XADataSource is an object used to manage distributed things. ConnectionPoolDataSource and XADataSource are transparent by the driver provider, which is transparent to the designer of the application. Like basic DataSource, system administrators configure ConnectionPoolDataSource and XADataSource objects.

Fourth, the result set:

The result set object is a row of data of the container. According to the purpose, it can be achieved by a variety of ways. RowSet and its associated interface are a bit different from the standard expansion API of JDBC2.0. They are not part of the drive, and RowSet is implemented on the upper layer of driver, which can be implemented by anyone.

All types of ROWSET implements the ROWSET interface, and the ROWSET interface extends the ResultSet interface. This RowSet object has a RESULTSET object. You can get a certain value in the database through the getxxx method. You can modify a certain column value via the Updatexxx method. You can move the cursor, which is the current line change to another.

Of course, we are more interested in the new features provided by the ROWSET interface. As a JavaBean component, the RowSet object can add or delete a Listener, you can get or set it attribute values. In these properties, one is a string, indicating a database QUERY request, the ROWSET interface defines setting parameters. The method also provides a method of executing this request. This means that the RowSet object can perform a query request, which can be calculated based on the result set it produces. Similarly, RowSt can also be calculated according to any table data source, so it is not limited to relational databases.

After the data is obtained from the data source, the RowSet object can be disconnected and the RowSet can also be serialized. This way, RowSet can be passed to the thin client via the network.

The ROWSET can be reconnected to the data source, so that the modifications you can save back to the data source. If a Listener is generated, the listener will receive a notification when the current row of the Rowset is modified. For example, graphical user interface components can be registered as a listener. When RowSet changes, the graphical user interface receives notifications, you can modify the interface to meet the RowSet it represent.

According to different needs, the ROWSET interface can be implemented in a variety of ways. Java Software has already written a cachedrowset implementation from http://developer.java.sun.com/developer/earlyaccess/crs/index.html. This implementation can be obtained. Similar to the CachedRowset class is that the JDBcrowSet class always keeps a connection to the data source. In this way, it is simple to add a layer on the surroundings of ResultSet, which is the same as a simple JavabEan component based on JDBC technology.

Summary: JDBC2.0 Standard Extended API The JDBC technology expands the JDBC technology into a brand new concept by following seeing DataSource. Make the code's code more delicate and easy to control. The new API supports the connection pool, supports distributed transactions. Finally, the Java application can spread the result set on the network, which is the RSULTSET that cannot be scrolled into rolling RowSet.

转载请注明原文地址:https://www.9cbs.com/read-29938.html

New Post(0)