Hibernate was used in the project. Later, the connection was automatically disconnected when MySQL was idle for 8 hours. In this way, the s3p0 connection pool was used to try. Which of the following errors still persists:
Com. mchange.
don't say anything, directly on the code:
${jdbc.driverClassName} ${jdbc.url} ${ jdbc.username} ${jdbc.password} ${jdbc.minPoolSize} &L t;! --The maximum number of connections that are kept in the connection pool. Default:15--${jdbc.maxpoolsize} ${
Background:C3P0 Connection PoolJdbc.maxpoolsize=1Jdbc.minpoolsize=1Jdbc.initialpoolsize=1Connection conn = Datasource.getconnection ()After the Close method is executed, the connection is really closed instead of being put back in the connection
1. Import the jar package:Hibernate-release-4.3.5.final/lib/optional/*.jar2. Join the configuration:10 5 2 2000 2000 10hibernate.c3p0.max_size: Maximum number of connections to the database connection
Why use a connection pool
-Our initial JDBC Connection database requires1. Installation drive2. Get Connected3. Open the Window4. Writing statements, executing statements, and viewing results5. Close the connection to the database1, 2, and 5 are
First create a new MAVEN project, Pom.xml configured to
4.0.0 com.jinzhe jinzhe 0.0.1-SNAPSHOT jar jinzhe http://maven.apache.org utf-8 junit junit 3.8.1 test c3p0 c3p0 ch.qos.logback logback-classic 1.0.11 org.hibernate hibernate-
after deploying a normal application on the Windows platform to a Linux server, the error has been: com.mchange.v2.async.threadpoolasynchronousrunner$ Deadlockdetector@bbd1b-apparent DEADLOCK!!! Creating Emergency threads for unassigned pending
Policies for connection deallocation in Hibernate Hibernate.connection.release_mode There are four properties:Defaults: Default modeThe connection is released when the On_close:session is closed.After_transcation: The release of a connection as a
Configure MySQL to be taken in a jndi way when the Meta-inf folder creates the Jndi for the Context.xml configuration application. Advantages for each application of independent jndi.
The configuration file and its steps are as follows:
1, Meta-inf
before 43.2 seconds. How can this problem exceed "wait_timeout? In addition, the configuration of the MySQL database is indeed 28800 seconds (8 hours). What about this?[Html]View plaincopy The update process in the program is roughly as follows:[Java]View plaincopySession = org. hibernate. SessionFactory. openSession (); transaction = session. beginTransaction ();Session. update (something); transaction. commit ();Session. close (); here, all the connections and closures about the database Conn
:1.7.0_51] at Com.mysql.jdbc.Util.handleNewInstance (util.java:411) ~[mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.SQLError.createCommunicationsException (SQLerror.java:1129) ~[mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.send (mysqlio.java:3988) ~[ Mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:2598) ~[ Mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.sqlQueryDirect (mysqlio.java:2778) ~[ Mysql-connector-java-5.1.29
Any DAO Access database, you first need to configure the data source, the data source defines a common configuration to access the database. You have a data source to create a data template, and then you inject the data template into the DAO, and you manipulate the database by invoking the appropriate method in the data Access template.The commonly used definition data source technologies are:1.JDBC, the most basic configuration, because there is no pooling management, each connection request wi
called a data source in English. The data source includes the implementation of the database connection pool.(2) some open source organizations also provide independent implementation of data sources:DBCP database connection pool (tomcat)C3P0 database connection pool (hibernate)(3). in actual applications, you do not need to write database connection code to directly obtain the database connection from the data source. Programmers should also try to
MySql database connection pool
1. Traditional links (as shown below)
Note:
(1). the traditional method of finding DriverManager to connect is limited.
(2). the traditional method of close () does not reuse the Connection, but only cut off the bridge between the application and the database, that is, no SQL command is sent to the database for execution.
(3) In the project, the Connection pool is used instead of DriverManager.
2. Use the connection pool ()
3. open source database connection pool
-5.1.29.jar:na] at Com.mysql.jdbc.SQLError.createCommunicationsException (SQLerror.java:1129) ~[mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.send (mysqlio.java:3988) ~[ Mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:2598) ~[ Mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.MysqlIO.sqlQueryDirect (mysqlio.java:2778) ~[ Mysql-connector-java-5.1.29.jar:na] at Com.mysql.jdbc.ConnectionImpl.execSQL (connectionimpl.java:2828) ~[ Mysql-conn
(Tomcat)C3P0 Database connection pool (Hibernate)(3). The actual application does not need to write the connection database code, directly from the data source to obtain the database connection. Programmers should also use the implementation of these data sources as much as possible to improve the database access performance of the program.
Use of 4.c3p0:(1). Under the Classpath path, configure the XML
Tags: Connection pool interrupt St Table Mon Summary call must C3P0 ASI For the configuration cognition of Org.apache.commons.dbcp.BasicDataSource, the configuration cognition of Org.apache.commons.dbcp.BasicDataSource "turn" Spring contains two implementations of data sources in third-party dependency packages, one of which is Apache DBCP and the other is c3p0.
You can use either of the two configuration
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.