Issue 21 - Connection Pooling Proxol
Code {font-size: 12px; font-family: Verdana; Color: 509050; Letter-spacing: 0px; line-height: 16px;}
Input {font-size: 12px; font-family: verdana; color: 000000; Background-Color: ffffff}
. copyright {font-size: 10px; font-family: verdana; color: 303030; letter-spacing: 0px; line-height: 16px;}
.list {font-size: 10px; Font-Family: Verdana; Color: 202020;
Author: jini Source: java open source newspaper stated: without the author's consent, declined to reprint
Proxool (ASF) JCP (Java Community Process) is a public organization responsible for Java SPEC standards, Reference Implementations (RI: Implementation), Open Organization of TECHNOLOGY Compatibility Kits, All and Java related companies, Sun, IBM , BEA, ORACLE, SAP, HP, etc Things, compatibility part is very weak, the products that manufacturers have realized each other will cause the system to integrate heavy burden, so I suggest everyone with a heavy mood, if you find what you do, and the standard does not match, Or standards with the same similar function, but also the time, and the works of the flowers, which makes the future maintenance personnel are the most sad place. Everything has exceptions, some more than the standard, Or the leading standard thing, you can learn, for example, log4j is much better than JDK logging, Hibernate can compete with EJB, this example is very much, but there is the same feature, it is OpenSource, because OpenSource can Adding more excellent people to strengthen, come to create! Back to this week theme, Connection Pooling achievement, many people don't know how Connection Pool is truly realized, currently more famous DB Connection Pool project has Jakarta Commons-DBCP , Poolman, RP Database Connection Pool, etc., as well as the proxool to be introduced, is used in many projects, the most famous is a powerful or-mapping project Hibernate and JMS project OpenJMS.
Increase the license instructions, please refer to the license explanation [by Tempo] PS: If you want to spide the newsletter, please contact us -> Johnny
This week's theme - ProxoolSECTION 01 Why need Connection Pooling When we enter Java's development world, Pool is also a learning, how to make Connection to connect with DB, and later people can use Connection already existing in pool, reduce The time, such excellent features, all of which have been implemented in many Application Server, as long as you simply follow the instruction file configuration, including the maximum connection number, the initial connection number, the maximum number of waiting quantities, etc., of course, Tomcat also has Create a CommONS-DBCP-related Connection Pooling mechanism, please review Tomcat JNDI Datasource setting !! And Proxol is a powerful connection poibility project, compatible with JDK 1.3 and 1.4. It has also achieved monitoring, record, etc. There is a very complete solution. Download area, current version 0.7.2Http: //sourceForge.Net/Projects/Proxool/ section 02 Setting adminservlet First, you have to put Download all the JAR files under Proxol Lib, put it under Web-INF / LIB, in addition, put your JDBC Driver is also the same LIB, then configure /Web-inf/web.xmlweb.xml
XML Version = "1.0" encoding = "UTF-8"?>
Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"
"/Web-inf/dtds/web-app_2_3.dtd">
servlet>
servlet-maping>
web-app>
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
Xml Version = "1.0" encoding = "ISO-8859-1"?>
ANYTHING OUTSIDE The "Proxool" tag is ignored. ->
driver-property>
proxool>
Something-Else-Entirely>
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.
XML Version = "1.0" encoding = "UTF-8"?>
Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"
"/Web-inf/dtds/web-app_2_3.dtd">
Org.LogicalCobwebs.Proxool.configuration.ServletConfigurator
servlet-class>
init-param>
servlet>
Org.LogicalCobwebs.Proxool.admin.Servlet.AdminServlet
servlet-class>
servlet>
servlet-maping>
web-app>
In the program, you only need to use the alias to call the Connection Pool to use <% @ 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.
Reference - related books or related articles
Proxool: http://proxool.sourceforge.net/ Proxool API: http://proxool.sourceforge.net/api-dev/index.html
News - OpenSource News
2003/07/30 - Poi 2.0-pre3 Released 2003/08/01 - Tomcat 4.1.27 Stable Released 2003/08/01 - Commons HttpClient 2.0 Release Candidate 1 Released