also the concept of connection pooling. I think this connection pool is mainly through the reuse of the connection, thus more efficient implementation of the response to user requests. The common connection pool developed for java is mainly dbcp and c3p0, of course, after understanding the principle of connection pooling, users can also develop and create self- connection pool. Database connection Pooling principle: can refer to this article, no
Create a C3P0 Data Source
When creating a C3P0 data source, there are very few connections to the database using JDBC in actual development. Generally, the data source is used. C3P0 is an open source data source, and the actual project is used a lot:
1. Added support for maven.
c3p0
When the concurrency is large, the c3p0 connection pool displays the following exception:
Caused by: Java. SQL. sqlexception: an attempt by a client to checkout a connection has timed out. at COM. mchange. v2. SQL. sqlutils. tosqlexception (sqlutils. java: 106) at com. mchange. v2. SQL. sqlutils. tosqlexception (sqlutils. java: 65) at com. mchange. v2.c3p0. impl. c3p0pooledconnectionpool. checkoutpooled
Spring uses annotations to configure C3P0 connection pooling and DAO use JdbcTemplate
1.Spring Configuration c3p0 Connection pool
Step one: Import the C3P0 jar package
Jar Package Download
Step Two: Create the spring configuration file and configure the connection pool
This is what we write when we write the C3P0 conn
Tags: database connection pool DBCP c3p0 Javac3p0 is an open source JDBC Connection pool that implements the data source and Jndi bindings to support the standard extensions of the JDBC3 specification and JDBC2. The open source projects that currently use it are hibernate,spring and so on. C3P0 data sources are used more in project development.1. c3p0 Difference
connection in the database connection pool object and the number of connections does not reach the maximum (that is, the maximum number of active connections). If the maximum number of connections is reached, the number of pre-determined connections is created.(4) The database access operation.(5) Close the database, release all database connections (at this point, close the database connection, not really shut down, but put it in an idle queue.) Release the connection if the number of actual i
1. Importing the JAR PackageC3p0-0.9.1.jarmchange-commons-java-0.2.3.4(Note: The jar package is a C3P0 database connection pool of auxiliary packages, no this package system will be reported when the boot ClassNotFoundException, This is the c3p0-0.9.2 version after the separation of the package, 0.9.1 when a package will be done)2. Get the connectionC3P0 is implemented in three ways.1. Write your own code t
First, c3p0 downloadC3p0:http://sourceforge.net/projects/c3p0/files/?source=navbar A compressed package is obtained after the download is complete.Ii. Configuring a Jndi data source using C3P0When configuring a Jndi data source in tomcat6.x, the default is to use the tomcat6.x dbcp connection pool, tomcat6.x Configure the Jndi data source with the DBCP connection pool as follows:1 If you want tomcat6.x to
C3P0 database connection pool,
Use the C3P0 database connection pool
1. Copy jar package: c3p0-0.9.1.2.jar c3p0-0.9.1.2-jdk1.3.jar c3p0-oracle-thin-extras-0.9.1.2.jar (oracle required)
2. Write the preparation file under the src directory:
1 C3P0 IntroductionC3P0 is also open source free connection pool! C3P0 is favored by many people!2 Use of C3P0Package Com.cug.c3p0;import Java.beans.propertyvetoexception;import Java.sql.connection;import Java.sql.sqlexception;import Org.junit.test;import Com.mchange.v2.c3p0.combopooleddatasource;public class C3P0Demo {@Testpublic void Fun1 () throws Propertyveto
Label:db.properties
jdbc.user=root jdbc.password=admin Jdbc.driverclass=com.mysql.jdbc.driver Jdbc.jdbcurl=jdbc\:mysql\:///spring4 jdbc.initialpoolsize=5 jdbc.maxpoolsize=10
in Spring.xml
--
Test Code:
public class Test { public static void Main (string[] args) { applicationcontext ctx = new Classpathxmlapplicationcontext (" Beans.xml "); DataSource DataSource = (DataSource) Ctx.getbean (" DataSource "); System.out.pri
C3P0 jar Package and configuration file download address: Click to open the link 1c3p0 introduction
C3P0 is also an open source free connection pool. C3P0 is favored by many people. the use of 2c3p0
The pool class in C3P0 is: Combopooleddatasource.
public void Fun1 () throws Propertyvetoexception, SQLException {
comb
Label:MySQL Default one connection idle 8 hours will automatically disconnect, and then the program thought the connection can also be used, and then in use will appear communications link failure exception. You need to set up two steps at this point, sometimes just set up MySQL. One, add the following two lines in the MySQL configuration file (the Linux configuration file is a my.cnf,windows profile of My.ini) (the default value is 28800, the following value represents one year.) I heard that M
Tags: blog com cti Trace Direct driver Common nbsp remI. Encapsulating the database connection (similar to DBCP) 1. Download Https://sourceforge.net/projects/c3p0/?source=typ_redirect 2. Import jar Mchange-commons-java-0.2.11.jar C3p0-0.9.5.2.jar 3, write the configuration file C3p0-config.xml XML version= "1.0" encoding= "UTF-8"?>
now Tomcat is using the default Apache DBCP connection pool for the company framework. This kind of connection pool is from the Noble Apache Foundation. But the word of mouth is not very good, in the new version of Hibernate has abandoned the support for DBCP, replaced by C3P0. At first I also had hope for DBCP, plus various parameter settings, but none were valid. Later changed on the C3P0, using its testc
Recently I wrote a database collection program. The process is to periodically collect data from the SQLSERVER database to the Oracle database. Data is generated once an hour, and each time the data volume is about 2 W. Sping3 + hibernate4 is used in the environment. When C3p0 is used in the database connection pool, it is reported every time: c3p0connectionisalreadyclosed I started
Recently I wrote a database collection program. The process is to per
1.c3p0 use of data sources C3P0 is an open source JDBC connection pool that implements the data source and Jndi bindings, and supports the standard extensions of the JDBC3 specification and JDBC2. C3P0 has its own format file, as follows
Guide Jar Package:
Establishing a C3P0 conn
Mysql Tomcat C3p0 System Performance Tuning personal summary,
System Information
The application logic is to use c3p0 to query data in the database and return Json data over http.
1. the initial test result JMeter test result before optimization
No.
Type
Original
1000 data bigger
1
500 Connection
250 query/S
63q/S70q/S
2
1000 connections
255q/S
57q/S65
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.