Label:The Hibernate Development Group recommends the use of c3p0;The Spring Development Group recommends the use of DBCP;hibernate in action recommends using C3P0; DBCP in the database server cannot reconnect After you forcibly close the connection or the database service restarts two. DBCP connection pool is created faster than C3P0, and
1. Import the jar package:Hibernate-release-4.3.5.final/lib/optional/*.jar2. Add Configuration:hibernate.c3p0.max_size: Maximum number of connections to the database connection poolHibernate.c3p0.min_size: Minimum number of connections to the database connection poolHibernate.c3p0.timeout: The Connection object in the database connection pool should be destroyed when it has not been used for a long timeHibernate.c3p0.max_statements: Number of cached Statement objectsHibernate.c3p0.idle_test_peri
C3p0 connection pool configuration problems,
Correct configuration file
1
The whole process is to watch the video, but an error occurs in this line.
The correct format is "//"
DBCP and c3p0 are two database connection pools.Both connection pools are the connection pools recommended by hibernate.DBCP is a database connection pool that relies on the Jakarta commons-pool Object pool mechanism. The Tomcat data source uses DBCP.C3p0 is an open-source JDBC connection pool. It is released together with hibernate in the lib directory, including datasources objects for connection and statement pools that implement the jdbc3 and jdbc
connection pool (not the C3P0 connection pool used here) to get the database connection, so the connection pool must be constructed first.
Here are four actions: Add and delete and check
@Test public
Void Add () {
//because JdbcTemplate is dependent on the database connection pool, the connection pool is constructed first
Drivermanagerdatasource Drivermanagerdatasource=new Drivermanagerdatasource ();
Drivermanagerdatas
Java.io.filenotfoundexception:d:\javastudy\javaee\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\ Wtpwebapps\day_05\web-inf\lib\mchange-commons-java-0.2.3.4.jar (the system cannot find the file specified.) )The above exception, it is easy to think of importing Mchange-commons-java-0.2.3.4.jar package, but still can't solve the problem. This will appear"May 14, 2017 4:09:37 pm Com.mchange.v2.log.MLog Info: Mlog Clients using Java 1.4+ standard logging. "The correct approach should be: Import
C3P0 is a common data connection pooling technology (provided by third parties)is also based on the core class datasource.Dbcputils.javaPackage Com.itheima.b_dbcp;import Java.sql.connection;import Java.sql.sqlexception;import Org.apache.commons.dbcp.basicdatasource;public class Dbcputils {private static basicdatasource DataSource; static{try {//Manually create connection Pool DataSource = new Basicdatasource ();//Set parameters//* Basic Datasource.set
satisfies where condition, And the the transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.
isolaction settings for data sources
Tomcat Data SourceThe isolation is set for the data source. If we take Tomcat's data source, we just need to make a global configuration.
c3p0 Data Source
In general, we recommend using Tomcat to set up a data source, because in the war package, you do not need to c
Tags: stp thread get div blog pass DAO Roo RACThe use of jar packages, and the division of Layers C3p0-config.xml The default configuration, if not specified, is the most common recommendation for using this configuration default configuration at the very beginning. It's okay to put it anywhere else.-default-config> //127.0.0.1:3306/test2default-config> Jdbcutils PackageCn.itcast.tools; Importjava.sql.Connection;ImportJava.sql.ResultSet;Importjava
Label: 01.Spring built-in data source configurationClass:drivermanagerdatasourceFully qualified name: Org.springframework.jdbc.datasource.DriverManagerDataSourceNo need to add any jars DBCP data source configuration for 02.apacheClass:basicdatasourceFully qualified name: Org.apache.commons.dbcp.BasicDataSourceNeed to add: Com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jarCom.springsource.org.apache.commons.pool-1.5.3.jar Data source configuration for 03.C3P0Class:combopooleddatasourceFull
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.