can be either properties or close XML. Of course, XML is a bit more advanced. However, the configuration file name for C3P0 must be c3p0-config.xml and must be placed under the classpath.public void Fun2 () throws Propertyvetoexception, SQLException {combopooleddatasource ds = new Combopooleddatasource (); Connection con = ds.getconnection (); System.out.println
Basicdatasource provide a close () method for shutting down the data source so that we can guarantee that the data source will be released successfully when the spring container is closed.C3P0 has richer configuration properties than DBCP, which allow for a variety of effective control over the data source:Acquireincrement: When a connection in the connection pool is exhausted, C3P0 creates the number of n
o'clock, indicates no limit;maxwait: The maximum number of seconds to wait, in milliseconds, over time will be reported error message;validationquery: A query SQL statement that verifies that a connection is successful, the SQL statement must return at least one row of data, as you can simply set to: "SELECT COUNT (*) from user";removeabandoned: Whether self-interruption, default is false;removeabandonedtimeout: The data connection is automatically disconnected after a few seconds, and the valu
can guarantee that the data source will be released successfully when the spring container is closed. C3P0 has richer configuration properties than DBCP, which allow for a variety of effective control over the data source:
Acquireincrement: When a connection in the connection pool is exhausted, C3P0 creates the number of new connections at once;
Acquireretryatte
1, using Org.springframework.jdbc.datasource.DriverManagerDataSource
Description: Drivermanagerdatasource to establish a connection is as long as there is a connection to create a new connection, there is no connection pool role.
The third way is to configure the data source in the Web server, which is not easy to deploy, and I recommend that you configure the data source in every two ways.
Configure a data sourceSpring contains two implementation packages of data sources in third party d
Tags: database connection file name strip ATI CTI Shu Fetch number PostBefore the text
In the previous article, we talked about the traditional way of JDBC connecting MySQL, but it was inefficient and obviously not as efficient as the connection pool when making multiple connections, so let's explain one of the JDBC connection pools this time: c3p0
Body 1. Preparatory work
IntelliJ idea
Reprint from http://feicer.javaeye.com/blog/549822
The Hibernate connection pool algorithm is quite immature. It's just to get you started, and it's not suitable for product systems or performance testing. For best performance and stability you should use a third party connection pool. You only need to replace the hibernate.connection.pool_size with the settings for a specific connection pool. This will turn off Hibernate's own connection pool. For example, you might want to use
An error occurred while connecting c3p0 to the database,
Error: java. SQL. SQLException: No suitable driver
Obviously, c3p0 does not find the corresponding configuration file (c3p0-config.xml or c3p0. properties), so it cannot connect to the database to report an error
connection.autocommit properties are true.That receives a string ofIn a c3p0-config.xml file, you can configure multiple connections. In addition to the default connection, the others are called named Connections. PassSpecify a named connection:"db909">"Checkouttimeout">1000"Idleconnectiontestperiod">30"initialpoolsize">2"MaxIdleTime">30"maxpoolsize">5"minpoolsize">2"maxstatements">50"acquireincrement">3"D
Tomcat is running well. The boss said the server is down. Hurry and check it out...
It is still running, but an error is reported ......
A little problem. Restart tomcat. So... restart...
The problem of C3P0-0.9.1.jar package appeared:
16:15:57. 500 [COM. mchange. v2.c3p0. c3p0registry]-[info] initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? True;
Note: required jar packages:
C3p0-0.9.1.2-jdk1.3.jarC3p0-0.9.1.2.jar
C3p0-oracle-thin-extras-0.9.1.2.jar
You also need a configuration file to store the database connection data.
DB. Properties
Package CN. c3p0;Import java. SQL. connection;Import java. SQL. resultset;Import java. SQL. sqlexception;Import com. mchange
Label:The contents of the C3P0 connection pool configuration XML file are as follows: C3P0 has richer configuration properties than DBCP, which allow for a variety of effective control over the data source: Acquireincrement: When a connection in the connection pool is exhausted, C3P0 creates the number of new connect
Tags: named user data CTO drive with SRC Stream implementationDBCP: (Understanding)Apache OrganizationSteps to use:1. Importing jar packages (Commons-dbcp-1.4.jar and Commons-pool-1.5.6.jar)2. Using the API 1 //hard-coded2 //Create a connection pool
3Basicdatasource ds =NewBasicdatasource ();4
5 //configuration Information
6Ds.setdriverclassname ("Com.mysql.jdbc.Driver"); 7Ds.seturl ("Jdbc:mysql:///day07"); 8Ds.setusername ("root"); 9Ds.setpassword ("1234"); Ten //configuration file One //imple
Poor memory: 22-JAVA database connection pool C3P0, 22-javac3p0
C3P0 is an open-source JDBC connection pool that implements data source and JNDI binding and supports JDBC3 specifications and standard extensions of JDBC2. Currently, open-source projects using it include Hibernate and Spring. C3P0 data sources are used in many projects.
1. Difference Between
Tags: des blog io ar os using Java SP files1.C3P0 IntroductionC3P0 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. The open source projects that currently use it are hibernate,spring and so on.The core class of the C3P0 database connection pool is CombopooleddatasourceUse
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.