Common Properties of 2.hibernate.cfg.xml ①JDBC Connection Properties >connection.url: Database URL >connection.username: Database user name >connection.password: Database user password >connection.driver_class: Database JDBC Driver >dialect: The dialect of the configuration database, which produces different SQL statements depending on the underlying database, Hibernate optimizes access for database feat
you create a DataSource, if you do not specify its attributes, c3p0 provides the default attribute value, which is implemented by hard encoding. However, you can also rewrite these attribute values by using the configuration file. If you rewrite these attributes by using the configuration file, you need to put the configuration file under CLASSPATH or where ClassLoader can find them.
C3p0 data sources can
failOverReadOnly = false maxReconnects = 10 to the connection string does not help;
The following idle verification does not work either:
Shouldn't c3p0 be so stable? Will the connection pool of c3p0 be useless at all? We began to suspect that the c3p0 configuration was correct. So we used the show processlist command to verify our connection pool. We found
Java uses c3p0 to manage database connection pools and c3p0 database connections
Database Connection Pool class, used to obtain database connections. The Singleton mode ensures that all connections are managed only through one connection pool.
package com.mousewheel.dbcon;import java.io.InputStream;import java.sql.Connection;import java.sql.SQLException;import java.util.Properties;import com.mchange.v2.
[C3p0] Article 1: a simple introduction to c3p0,Preface
According to the c3p0-0.9.5.1 version of the official documents, coupled with their own understanding, compiled into the translation. Limited capabilities. If the translation content is incorrect or your understanding is biased, please correct it!
What is c3p0?
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.
The preferredtestquery attribute is ignored. You cannot perform any operation on this test table. It will only be used for c3p0 testing.. Default: NULL -->Retained, and continue to g
Prefacethe translation is based on c3p0-0.9.5.1 version of the official documents, plus their own understanding, collation translation. The ability is limited, if the translation content is wrong or understanding has the deviation, also please everybody corrects! What is c3p0C3P0 is a very useful jar class library that is defined by the standard Extensions section of the JDBC3 specification and JDBC2 specification, making traditional JDBC more suitabl
. min_size
C3p0. testconnectionsoncheckout
Hibernate. c3p0. ValidateHibernate 2.x only!
Remember --These, andOnly these, Properties must be defined in your hibernate configuration,Or else they will be set to hibernate-specified defaults. All other configuration properties that you wish to set shoshoul
Database connection Pool C3P0 Framework is a very good open source jar, high-performance management of the data source, here only to discuss the program itself is responsible for the data source, do not discuss container management.First, the realization way:C3P0 is implemented in three ways:1. Write your own code to implement the data sourceFor example: Configure a property file under the Classpath, Config.properties, with the following:Driverclass=x
properties, and so on when creating data source objects. All pool management operations are completely transparent to the user after the data source object is created.
There are three ways to create a C3P0 data source: Instantiate directly, configure a combopooleddatasource bean. Use the data source factory class. Create a personal data source with pooled technology: instantiate Poolbackeddatasource direct
c3p0 configuration (we have a minimum of 5 connections):Where is the reason? The following classes are available in the Hibernate core pack:It can be seen that hibernate's original ecology supports C3P0. So how can you let hibernate recognize these configurations?View the source code for the Org.hibernate.connection.ConnectionProviderFactory class in the Hibernate core package. Can see the following gaze:i
bindings, and supports the standard extensions of the JDBC3 specification and JDBC2. C3P0 is generally used with a frame such as hibernate,spring, and of course it can be used alone.DBCP does not automatically reclaim idle connections, C3P0 has the ability to automatically reclaim idle connections.The first way: Configure with an XML fileXML version= "1.0" encoding= "UTF-8"?>
From: http://blog.csdn.net/fenglibing/article/details/4100272
Hibernate built-in connection pool Algorithm Relatively immature. It is only intended to help you get started quickly and is not suitable for product systems or performance tests. For the best performance and stability, you should use a third-party connection pool. You only need to replace hibernate. Connection. pool_size with the settings of a specific connection pool. This will disable the connection pool that comes with hibernate.
Spring -- c3p0 configuration details
Today, let's talk about the c3p0 configuration in Spring in detail. Well, we will go directly to the topic without delay. Please refer to the specific configuration file below:
Com. mysql. jdbc. Driver
Jdbc: mysql :/// 192.168.3.110: 3306/DBName? UseUnicode = t
1: The first way is very simple
C3p0.driverclass=com.mysql.jdbc.driver
c3p0.jdbcurl=jdbc:mysql://localhost:3308/database
c3p0.user= Root
c3p0.password=root
File name: C3p0.properties (placed under the SRC directory)
The program
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.