Database connection buffer pool (original)

xiaoxiao2021-03-06  40

A database buffer pool refers to a physical connection cached in a memory space, which can be reused. Database buffer pool is important for improving the performance of Java database applications, especially when this Java database application is running in an intermediate server environment.

The data buffer pool exists in the intermediate layer server environment, which can be called by different Java applications. The Javax.sql.rowset package adds support for buffer data sources to connect the buffer pool buffer database connection as a real data source service. The ROWSET package provides several interfaces to process database buffer pools, and the main interfaces are: 1. DataSource interface: The instance object of the DataSource interface represents buffer data source services existing in the intermediate layer server. Using it can return a database connection in the database buffer pool, the instance object of the DataSource interface is actually a provider of a JNDI service. Before using it, the JNDI service object must be registered in the intermediate layer server environment, and A service name is bound together, then it can be called by other Java applications. 2, ConnectionPoolDataSource interface: This interface can be used to create a database physical connection buffered in the buffer pool, which may be called by instance objects of the DataSource interface. 3, PooledConnection interface: This interface represents a buffered database connection, which defines a getConnection () method to use this method to return an instance object of the java.sql.connection interface. How to use the ROWSET package defined class and interface to operate the database buffer pool, the following JSP code segment provides a simple incomplete example

example

<%

Context ctx = new initialContext ();

DataSource DS = (Datasource) CTX.lookup ("JDBC / EMPLOYEDB");

// First Get a connection. Connection Pooling Is Done

// INTERLY by The DataSource Object.

Connection Con = DS.GetConnection (JDBC / WebDatabase "" SA "" ");

// do all the work as a single transaction (optional).

Con.SetAutocommit (False);

// The actual work (queries and updates).

// Work Is Done Using Standard JDBC Code As Defined in T

// REST OF THE JDBC API.

// commit the transaction.

C.Commit ();

// close the connection. This return the underlying physical

// Database Connection to the pool.

C. close ();

%>

The operation mechanism of the JSP code segment above is as follows

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

New Post(0)