Introduction to Connection Database connection pool
In a traditional two-tier structure, the client program opens the database connection at startup and closes the database connection when exiting the program. In this way, each client always occupies a database connection throughout the program, even when there is a large amount of idle time without a database operation, such as when the user enters data, resulting in inefficient use of the database connection.
In three-tier structure mode, the database connection is managed through the connection pool of the middle tier. Only when the user really needs a database operation does the middle tier request a connection from the connection pool, the database operation completes, and the connection is immediately released into the connection pool for use by other users. In this way, not only greatly improve the efficiency of database connection, so that a large number of users can share fewer database connections, and eliminates the time to establish the connection.
Connection Pool Configuration Usage
Database connection pooling is a basic function of the application server, and we take Apusic application server as an example to illustrate the configuration usage of the JDBC Connection pool.
The Apusic JDBC Connection pool provides support for a variety of databases, such as Oracle, MS SQL Server, Sybase, Informix, DB2, and so on.
The Apusic JDBC Connection pool can be connected to a database through the JDBC driver of the database itself, or through the Jdbc-odbc bridge. Let's take Oracle as an example to illustrate how to configure a connection pool:
The JDBC driver package file for the Oracle database Classes111.zip in/usr/oracle/jdbc/lib (assuming Oracle's installation directory is/usr/oracle) directory, First, the Classes111.zip is added to the classpath of the system. Then set the following in apusic/config/apusic.conf (assuming the installation directory is Apusic):
Expirationtime: Timeout time, in seconds. When a database connection exceeds the Expirationtime set time is not used
, the system automatically closes the database connection. Default value is 300 seconds
Mincapacity: Minimum number of connections
URL: URL of the database
ConnectionProperties: Connection properties, where: User username, password password
DRIVERCLASSNAME:JDBC Driver class Name
Maxcapacity: Maximum number of connections
The IP address of the computer on which the 192.168.19.136:oracle resides.
Calling connection pooling
Let's take a JSP program as an example of how to use connection pooling. First we get datasource through Jndi, then we get the connection connection, as shown in the following example:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.