[Hibernate uses the Tomcat connection pool to connect to the database] Step 1: In tomcat/conf/context. configure the connection pool information in the xml file. [html] <Resource auth = "Container" driverClassName = "com. mysql. jdbc. driver "maxActive =" 100 "maxIdle =" 30 "maxWait =" 10000 "name =" jdbc/testDB "password =" "type =" javax. SQL. dataSource "url =" jdbc: mysql: // 192.168.0.103: 3306/testDB? AutoReconnect = true & amp; useUnicode = true & amp; characterEncoding = UTF-8 "username =" root "/> where the name attribute is the data source name, usually adopt jdbc /**. the type attribute is the data source method. The driverClassName attribute is the driver name. (This is the oracle driver) username, password, database name and password url: The Path to the database to be accessed. The content composition of the url has been analyzed in the previous blog. The maxActive attribute is the maximum number of concurrent connections. If it is set to 0, there is no limit. The maxWait attribute is the maximum connection time waiting for the connection. The maxIdle attribute is the number of idle connections in the connection pool. MaxActive = "4" in the preceding settings indicates that the maximum number of connections is 4. If a connection is established, an exception occurs. MaxIdle = "2" indicates that when the database is closed (instead of actually disconnecting, it is returned to the connection pool), the maximum number of idle connections in the connection pool is two. If there is another connection, if there is no idle connection in the connection pool, but it does not reach the maximum number of maxActive concurrent connections, then establish a connection in the connection pool. Ps: some textbooks Tomcat configuration connection pool, need to add the driver package in Tomcat/lib [mysql: mysql-connector-java.jar; oracle: ojbc14.jar. ], but when you configure the connection pool under Tomcat7.0, the jar package that is not added to the driver still runs normally. Step 2: To use the Tomcat connection pool in Hibernate, you only need to configure the <SessionFactory> element as follows: [html] <? Xml version = '1. 0' encoding = 'utf-8'?> <! DOCTYPE hibernate-configuration PUBLIC "-// Hibernate/Hibernate Configuration DTD 3.0 // EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">