A configuration method of proxool connection pool

Today I look at the connection pool configuration file of an old system, using Struts1:

1. Configure the connection pool controller in web.xml
<servlet>
	  <servlet-name>poolMonitor</servlet-name>
	  <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
	</servlet>

	<servlet-mapping>
	  <servlet-name>poolMonitor</servlet-name>
	  <url-pattern>/poolMonitor</url-pattern>
	</servlet-mapping>	

2. Others are configured directly in spring
<bean id="connectionProvider"		class="com.uncnet.base.database.proxoolsupport.ProxoolConnectionProvider"
		init-method="init">
		<property name="configFile">
			<value>/proxool.xml</value>
		</property>
	</bean>

	<bean id="myDataSource" class="com.uncnet.base.database.ConnectionProviderDataSource">
		<property name="connectionProvider">
			<ref local="connectionProvider" />
		</property>
		<property name="param">
			<value>spring</value><!-- refers to the alias of the connection pool -->
		</property>
	</bean>


3. Configure various connection parameters of the database and connection pool parameters in proxool.xml, the programmer only needs to call "myDataSource". myDataSource is put into sessionFactory to inject DAO, and is also put into
TransactionManager for transaction control.
<alias>spring</alias>
<driver-url>jdbc:oracle:thin:@192.168.5.186:1521:orcl</driver-url>
		<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
		<driver-properties>
				<property name="user" value="hebxzsp" />
 				<property name="password" value="HeBeXzSP#2015" />
		</driver-properties>

<minimum-connection-count>1</minimum-connection-count>
		<maximum-connection-count>20</maximum-connection-count>
		<maximum-connection-lifetime>18000000</maximum-connection-lifetime>  5 hours orcl
		<maximum-active-time>1800000</maximum-active-time> 30 mins
		<house-keeping-test-sql>values(current TimeStamp)</house-keeping-test-sql>
		<statistics>15m,45m,1d</statistics>
		<statistics-log-level>WARN</statistics-log-level>

		<fatal-sql-exception>Connection is closed,SQLSTATE=08003,Error opening socket. SQLSTATE=08S01,SQLSTATE=08S01</fatal-sql-exception>
		<fatal-sql-exception-wrapper-class>org.logicalcobwebs.proxool.FatalRuntimeException</fatal-sql-exception-wrapper-class>
		<verbose>false</verbose>



Look at the three common open source connection pools introduced by others:

In order to facilitate the portability and configurability of the application, it is recommended to use jndi to configure the connection pool uniformly. There are actually many examples on how to configure it.
Here is a simple example (using the spring framework):
first, configure the jndi name in the context definition of the application, such as a resource.xml file, which is written as
    <bean id="dataSource" class= "org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName"><value>jdbc/myapp</value></property>
    </bean>
Pay attention to the configuration of the dataSource bean in the dao layer (hibernate or jdbc) The file needs to be configured as a property of the dataSource name in all beans
. "jdbc/myds" is the name of jndi. The next step is to connect the database in the application server connection pool and configure the corresponding jndi.

An open source data connection pool
1 dbcp
dbcp may be the most used open source connection pool, probably because it is easy to configure, and many open source and tomcat application examples use this connection pool.
This connection pool can set the maximum and minimum connections, connection waiting time, etc., and has basic functions. For the configuration of this connection pool, see: dbcp in the attached archive.



2 c3p0
c3p0 is another open source connection pool, which is also well-known in the industry. This connection pool can set the maximum and minimum connections, connection waiting time, etc., and has basic functions.
For the configuration of this connection pool, see: c3p0.xml in the attached archive.
Usage evaluation: In specific project applications, it is found that the stability of the continuous operation of this connection pool is quite good, and the stability is also guaranteed under the pressure of large concurrency.
          In addition, connection pool monitoring is not provided.
         
3 proxool
proxool connection pool may be used by relatively few people, but it also has a certain popularity. This connection pool can set the maximum and minimum connections, connection waiting time, etc., and has basic functions.
For the configuration of this connection pool, see the attached compressed package: proxool.xml.
Usage evaluation: In the application of specific projects, it is found that there are certain problems in the stability of the continuous operation of this connection pool. There is a task scenario task that needs to run batches for a long time. The same code is successfully completed
in the other two open source connection pools, but An abnormal exit occurred in proxool.
But proxool has an advantage - connection pool monitoring, which is a very attractive thing. The general configuration method is to add the following definitions to web.xml:
    <servlet>
        <servlet-name>admin</servlet-name>
        <servlet -class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>     
   </servlet>
   <servlet-mapping>
      <servlet-name>admin</servlet-name>
      <url-pattern>/admin</url-pattern>
   </servlet-mapping>  
and visit after the application starts: http://localhost:8080/myapp/admin this The url can be monitored.
However , the package of proxool itself will have encoding problems in monitoring and use. There is a
package to solve this problem in the attachment. See the attached compressed package: proxool-0.9.0RC3.jar. In addition, a jdk1.5 or above environment is required.

Summary moment:
To sum up, these open source connection pools have their own advantages and disadvantages. It is recommended to use c3p0. It has been tested that this connection pool has stable performance and strong pressure-bearing capacity. Although proxool has obvious performance problems,
it is recommended to use it during development and testing because of its monitoring function, which helps to determine whether any connections have not been closed, and can eliminate some code performance problems.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326856922&siteId=291194637