Tags: style blog color os using IO for AR dataAbout C3P0, DBCP and Proxool, such as the comparison, configuration on the internet has a lot of articles, I do not waste everyone's time, mainly on the following I have used these three after the experience.
DBCP: The framework used to be dbcp, Online said, there are many bugs, at least, these bugs, I have not encountered, from the situation of our system operation, can also, there is not too muc
Original address:
The difference between C3P0 and DBCP
https://blog.csdn.net/huangxinyu_it/article/details/50826463
C3P0 Introduction:C3P0 is an open-source JDBC connection pool that implements data source and Jndi bindings, and supports standard extensions for JDBC3 specifications and JDBC2. The open source project that uses it now has hibernate,spring etc.DBCP Introduction:DBCP (db connection pool),
This is an example I have seen on the internet before, I think c3p0 more mature, stable, in the general project to choose C3P0 to do database connection pool is better, so I posted in the Applicationcontext.xml file to configure an example of C3P0, for reference.
A new frame to do junit test times out of the following error.
Java.lang.Exception:DEBUG STACK TRACE for Poolbackeddatasource.close (). At Com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close (abstractpoolbackeddatasource.java:417) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETH
Today in doing a Java project to use the C3P0 data source, the program runs under Windows without any problems, but to the server (Linux environment) when the deployment of the runtime abnormal, the exception information is as follows:
2014-08-19 20:51:01 [INFO] Failed to get local inetaddress for VMID. This is unlikely to matter. At all.
We ll add some extra randomness java.net.unknownhostexception:w: W at Java.net.InetAddress.getLocalHost (Unknow
Label:(a) C3P0C3P0 is the recommended connection pool for hibernate, which automatically cleans up connection, Statement, ResultSet, and requires c3p0-dependent jar packages.Configuration filedriverclass=com.mysql.jdbc.Driver
jdbcurl=jdbc:mysql://127.0.0.1:3306/mydb
user=root
=w5566
maxpoolsize=40
minpoolsize=2
Initialpoolsize=10
maxstatements=180Java implementation PublicConnection C3p0conn () {//Load configuration fileProperties props =NewPropertie
Although DBCP is a widely used connection pool, I think that C3P0 has higher performance and stability on Tomcat. Here's how to use C3P0 in spring:
class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >Org.hibernate.dialect.Oracle9Dialect
Bind the Connection object to the current thread so that the link can be used in each method.Datasourceutils.javaPackage Com.itheima.utils;import Java.sql.connection;import Java.sql.resultset;import java.sql.SQLException;import Java.sql.statement;import Javax.sql.datasource;import Com.mchange.v2.c3p0.combopooleddatasource;public Class datasourceutils {private static Combopooleddatasource ds=new Combopooleddatasource ();p rivate static threadlocaljava-
DBCP Connection Pool configuration
About DBCP Connection pool The specific use of the method also need to refer to: Click to open the link dbcp jar package
Commons-dbpc.jar, Commons-collections.jar, commons-pool.jar download click to downloadc3p0 Connection Pool configuration
For more information on C3P0 connection pooling use: Click to open linkc3p0 jar Package
C3p0-0.9.2.jar Download Click to down
--------------------------------------------------------------------------------------------------------------- ----------------------------Import Com.mchange.v2.c3p0.ComboPooledDataSource;Combopooleddatasource pool=new Combopooleddatasource ();System.out.println (Pool.getproperties ());//the user name and password of MySQL can be exported here;for (int i=0;iConnection con=pool.getconnection ();System.out.println (Con.hashcode ());//This is the addres
pool can set the maximum and minimum connections, connection waiting time, etc., basic functions are available. The configuration of this connection pool is described in the attachment compression package: Dbcp.xmlUsage Evaluation: In the specific project application, it is found that the stability of the continuous operation of this connection pool is still possible, but the speed is slightly slower, the stability under the pressure of the large concurrent quantityThe connection pool monitorin
One, the XML file reads the. properties file to connect to the database1. Configuration in XML fileHowever, because the pre-cached statements belong to a single connection instead of the entire connection pool, setting this parameter takes into account a number of factors. If both maxstatements and maxstatementsperconnection are 0, The cache is closed. Default:0-->2. The Properties Property fileJdbc.initialpoolsize=20jdbc.maxpoolsize=100jdbc.minpoolsize=10jdbc.maxidletime=600Jdbc.acquireincremen
Package Com.itheima.c_c3p0;import Java.sql.connection;import Java.sql.sqlexception;import Javax.sql.DataSource; Import Com.mchange.v2.c3p0.combopooleddatasource;public class C3p0utils {//provide connection pool private static DataSource DataSource = New Combopooleddatasource ("Day17_config"); public static Connection getconnection () throws sqlexception{//the return datasource.getconnection () obtained from the connection pool; /** * Data source, Con
I think I was writing a connection pool myself before. Now there is no more than a large number of connection pools, and I guess I will never write it myself.
The following is an example of two connection Ms sqlserver. Connect to other databases and
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.