JDBC Connection Pool

Source: Internet
Author: User
Tags zip
Database connection pool introduction
In the traditional two-layer structure, the client opens the database connection at startup and closes the database connection when exiting the program. In this way, during the entire program running, each client always occupies a database connection, even if there is a large amount of free time without database operations, such as when the user inputs data, resulting in inefficient database connection.
In the three-tier structure mode, database connections are managed through the connection pool of the middle layer. Only when the user really needs to perform database operations, the middle layer applies for a connection from the connection pool. After the database operation is completed, the connection is immediately released to the connection pool for other users to use. This not only greatly improves the efficiency of database connections, but also allows a large number of users to share less database connections, saving the time for establishing connections.
Connection pool configuration and usage
The database connection pool is a basic function of the Application Server. We use Apusic Application Server as an example to describe how to configure and use the JDBC connection pool.
Apusic JDBC connection pool supports multiple databases, such as Oracle, MS SqlServer, Sybase, Informix, and DB2.
The Apusic JDBC connection pool can be connected to the database through the JDBC Driver of the database itself, or through the JDBC-ODBC Bridge. The following uses Oracle as an example to describe how to configure the connection pool:
The JDBC driverpackage file classes111.zip of the Oracle database is stored in the/usr/oracle/jdbc/lib Directory (assuming that the oracle installation directory is/usr/oracle1_directory, add classes111.zip to the CLASSPATH of the system first. Then make the following settings in apusic/config/apusic. conf (assuming the installation directory is apusic:
<SERVICE
CLASS = "com. apusic. jdbc. PoolManager"
NAME = "JdbcPool: name = jdbc/sample"
>
<Attribute name = "ExpirationTime" VALUE = "300"/>
<Attribute name = "MinCapacity" VALUE = "5"/>
<Attribute name = "URL" VALUE = "jdbc: oracle: thin: @ 192.168.19.136: 1521: orcl"/>
<Attribute name = "ConnectionProperties" VALUE = "user = gtj, password = abc123"/>
<Attribute name = "DriverClassName" VALUE = "oracle. jdbc. driver. OracleDriver"/>
<Attribute name = "MaxCapacity" VALUE = "30"/>
</SERVICE>
ExpirationTime: the timeout time in seconds. When a database connection exceeds the expirationTime, it is not used.
The system automatically closes the database connection. The default value is 300 seconds.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.