The role of Dbutils:
Dbutils is an open source component of Apache, and for JDBC, dbutils can simplify heap JDBC operations because dbutils encapsulates the operation of JDBC.
main classes included in Dbutils:
1.QueryRunner class: Mainly for the operation of the database.
2.ResultSetHandler Interface: How to encapsulate the result set after the return of the Select.
3.Dbutils class: For closing resources and transaction processing.
C3p0 's intro
System InformationApplication logic is to query data with C3P0 to database and HTTP to return JSON data1 Initial test results prior to tuning JMeter test result
No.
Type
Original
Data bigger
1
500Connection
query/s
63q/s70q/s
2
Connections
255q/s
57q/sq/s
This data is the result of a database SELECT statement printed from the log of the program (which
The configuration file for the C3P0 database connection pool is placed in the SRC directory of Eclipse and the code is recognized.The contents of the C3P0 configuration file are as follows: For the specific configuration of C3P0, the file name is C3p0-config.xml: A problem was encountered when using the
have corresponding legal external addresses. However, the number of internal users is huge, and an external IP address is unrealistic. In this way, there is a concept called connection pool. Because not every user needs to access the Internet at the same time, when a user needs to access the Internet, he can obtain an external IP address from the connection pool to access the Internet. When the user no longer needs to access the Internet, the IP address is put back in the connection pool and ca
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. v2.c3
C3p0 can be used to connect to a database,
C3p0 can be used to connect to a database. Here, mysql is used as an example.
1. set parameters directly using the set method. Basic Method
ComboPooledDataSource dataSource = new ComboPooledDataSource ();DataSource. setDriverClass ("com. mysql. jdbc. Driver ");DataSource. setJdbcUrl ("jdbc: mysql: // localhost: 3306/mydb ");DataSource. setUser ("root ");DataSource.
The most common connection pooling technology, spring supports C3P0 connection pooling by default.Core class1. Combopooleddatasource ds;Introduced, C3P0 jar package2. Use a link pool to create a linkA) hard-coded mode Public voidTestcode ()throwsexception{//Create connection Pooling tool classCombopooleddatasource DataSource =NewCombopooleddatasource (); //Setting Connection ParametersDatasource.setjdbc
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 connections at once; Acquireretryattempts: Defines t
First import the Dbutils toolkit: Commons-dbutils-1.6.jar
And then import the C3P0 Toolkit: C3p0-0.9.1.2.jar
First create the C3P0 tool class:
Package star.july.util;
Import java.sql.Connection;
Import java.sql.SQLException;
Import Javax.sql.DataSource;
Import Com.mchange.v2.c3p0.ComboPooledDataSource;
p
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.checkoutPooledConnection ( c3p0pooledconnectionpool.java:527) at Com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection ( abstr
1.c3p0 OverviewC3P0 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. 2.C3P0 Tool KitHttps://sourceforge.net/projects/c3p0/files/latest/download?source=filesImport jar pac
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
Label:Several common bugs for database connection pooling: 1. Warning: com[email protected]76c7022e--apparent DEADLOCK!!! Creating Emergency threads for unassigned pending tasks! October 01, 2016 6:28:24 PM Com.mchange.v2.async.threadpoolasynchronousrunner$deadlockdetector Run More than 80% is due to similar problems such as data connection configuration or databases . There is a problem with the configuration in ①jdbc.properties Driverclassname Url ② does not have a corresponding database.
Tags: style os io using Java ar for file dataC3P0 Database Connection Pool usage1. 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 (required by Oracle)2, write the preparation file in the SRC directory: c3p0-config.xml (the name can only be this)3, Class C3p0utilC3p0-confi
C3P0: 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.
By default (that is, no connection pooling is configured), Hibernate uses a built-in connection pool. However, this connection pool performance is not good, so the official is only recommended in the development environment to us
DBCP, C3P0, Proxool, BONECP and other open source database connection pool Basic Introduction
Brief introduction
Use evaluation
Project Home
DBCP
DBCP is a database connection pool that relies on the Jakarta Commons-pool object pooling mechanism. DBCP can be used directly in the application
You can set the maximum and minimum connections, the connection wait time, and so on, the basic functions are, this co
Tomcat configuration connects to the c3p0 connection pool,
1. Configure the JNDI resource for Tomcat
JNDI (Java Naming and Directory Interface), Java Naming and Directory Interface.
The role of JNDI is to configure resources on the server and then obtain the configured resources in a unified manner.
The resource we want to configure here is of course the connection pool, so that the project can obtain the connection pool object in a unified way.
1. Im
connection pool, and of course there are connections using DBCP.
Method has the advantages and disadvantages of various methods. We have analyzed the advantages and disadvantages according to the actual situation.
For example, if a project is not a large project, and the hardware machines used
If it is not very good, it is estimated that there is no need to use the database connection pool. After all, the connection
The pool usually manages connections, which greatly occupies the running pe
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.