Database connection pool summary articles --- Proxool.jar

xiaoxiao2021-03-06  41

1.proxool.jar file can be

Http://sourceforge.net/projects/proxool/ download is available.

2.

Section 01 Why need the connection tooling when we entered the development of Java, Pool is also a learning, how to make the connection to the DB link, and later people can use the connection already Pool, reduce the time, so Excellent features have been implemented in many Application Server, you only need to simply follow the instruction file configuration, including the maximum connection number, the initial link number, the maximum number of waiting quantities, etc., of course, Tomcat also has built COMMONS-DBCP Connection pooling mechanism, please check

Tomcat JNDI Datasource Setting!!

And Proxol is a powerful Connection Pooling project, compatible with JDK 1.3 and 1.4. It has also achieved a function of monitoring, record, and more, it is a very complete set of projects with limited Connection, and paying attention to Performation. solution.

Download area, current version 0.7.2

http://sourceforge.net/projects/proxool/

Section 02 Set AdminServlet First, you have to download all the JAR files under Proxool Lib, put below Web-INF / LIB,

In addition, put your JDBC Driver is also put in the same LIB.

Then you are configured /Web-inf/web.xml

Web.xml

Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"

"/Web-inf/dtds/web-app_2_3.dtd">

proxool

admin

Org.LogicalCobwebs.Proxool.admin.servlet.adminServlet

admin

/ admin

Section 03 Creating a JSP or Dao Bean through Proxoldriver, establishing a Connection through org.logicalcobwebs.proxool.proxoldriver

Test.jsp

<% @ Page Import = "java.sql. *"%>

<%

Connection connection = NULL;

Try {

Class.Forname ("Org.LogicalCobwebs.Proxool.ProxoOLDRIVER");

Connection = DriverManager.getConnection

"Proxool.test: Org.gjt.mm.mysql.driver: JDBC: MySQL: // localhost: 3306 / test", "root",

"Password"

);

} catch (exception e) {

Out.println (e)

}

Out.println ("OK");

%>

Section 04 Viewing Pooling Today Perform http: // localhost: 8080 / proxool-test / admin (Proxool-Test is your app name) If there is no Pool state, you will only see the words of Pools, so You will perform http: // localhost: 8080 / proxol-test / test.jsp to create a connection, you can monitor the status of Connection Pooling.

Pools

> TEST -> JDBC: MySQL: // WWW: 3306 / Testdefintition for test

URLjdbc: mysql: // localhost: 3306 / testDriverorg.gjt.mm.mysql.DriverConnections0 (min), 15 (max) PrototypingoffConnection Lifetime11: 00: 00Maximum active time07: 05: 00House keeping sleep time30sHouse keeping test SQLoffFatal SQL exceptionsoffStatisticsoffSnapshot at 21: 12:53

Start Date01 - ?? - 2003 21: 12: 30connections1 (Active), 0 (Available), 15 (MAX)

Served1Refused0Details

#bornlaststartlap (ms) thread1 21:12:31 21: 12: 3122432 Thread-15less Information

Proxool 0.7.2 (29-APR-2003 00:33)

Section 05 Use Properties or XML to set the DB URL and Driver to use XML configuration files, using jaxpconfigurator.configure ("proxool.xml", false) in the program; configuration file settings are as follows

WEB-INF / Proxool.xml

ANYTHING OUTSIDE The "Proxool" tag is ignored. ->

XML-Test

JDBC: MySQL: // Localhost: 3306 / Test

Org.gjt.mm.mysql.driver

10

select current_date

You can also use Properties, in program printyconfigurator.configure ("proxool.properties"; file settings

WEB-INF / Proxool.properties

JDBC-0.Proxool.Alias ​​= Property-Test

JDBC-0.Proxool.driver-url = jdbc: mysql: // localhost: 3306 / TEST

JDBC-0.Proxool.driver-class = org.gjt.mm.mysql.driver

JDBC-0.User = root

JDBC-0.Password = Password

JDBC-0.Proxool.Maximum-connection-count = 10

JDBC-0.Proxool.House-Keeping-Test-SQL = SELECT CURRENT_DATE

If you use it in web, you can also set the servletconfigurator servlet to register in Web.xml.

Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"

"/Web-inf/dtds/web-app_2_3.dtd">

proxool

servletconfigurator

Org.LogicalCobwebs.Proxool.configuration.ServletConfigurator

XMLFILE

Web-inf / proxool.xml

1

admin

Org.LogicalCobwebs.Proxool.admin.Servlet.AdminServlet

admin

/ admin

In the program, you only need to use the alias to call the Connection pool to use the connection.

<% @ Page Import = "Java.sql. *;"%>

<%

Connection connection = NULL;

Try {

Class.Forname ("Org.LogicalCobwebs.Proxool.ProxoOLDRIVER");

Connection = DriverManager.getConnection ("proxool.xml-test");

} catch (exception e) {

Out.println (e);

}

Out.println ("OK");

%>

Section 06 Using Connection.Close () Close Connection Orders, I have not written close, I hope everyone remember to use Close () to shut down after the connection is finished, to avoid java.sql.sqlexception: ORG. LogicalCobwebs.Proxool.Proxoolexception: ConnectionCount IS 10. Maximum Connection Count of 10 Cannot Be Exceeded.

3.

Proxol - Configuration Settings