当前位置: 代码迷 >> 综合 >> java c3p0 连接池连接数量
  详细解决方案

java c3p0 连接池连接数量

热度:63   发布时间:2023-10-10 21:41:13.0
package cn.it.datasource.c3p0;import com.mchange.v2.c3p0.ComboPooledDataSource;import java.sql.Connection;
import java.sql.SQLException;public class Demo2 {public static void main(String[] args) throws SQLException {// 1.获取DataSourceComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();// 2.获取连接for (int i = 1; i <= 11; i++) {Connection connection = comboPooledDataSource.getConnection();System.out.println(i+":"+connection);if(i == 5){connection.close();}}}
}

1:com.mchange.v2.c3p0.impl.NewProxyConnection@49c386c8 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@56528192]
2:com.mchange.v2.c3p0.impl.NewProxyConnection@96def03 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@5ccddd20]
3:com.mchange.v2.c3p0.impl.NewProxyConnection@1f3f4916 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@794cb805]
4:com.mchange.v2.c3p0.impl.NewProxyConnection@59d016c9 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@3cc2931c]
5:com.mchange.v2.c3p0.impl.NewProxyConnection@3967e60c [wrapping: com.mysql.cj.jdbc.ConnectionImpl@60d8c9b7]
6:com.mchange.v2.c3p0.impl.NewProxyConnection@433d61fb [wrapping: com.mysql.cj.jdbc.ConnectionImpl@60d8c9b7]
7:com.mchange.v2.c3p0.impl.NewProxyConnection@4b14c583 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@65466a6a]
8:com.mchange.v2.c3p0.impl.NewProxyConnection@1534f01b [wrapping: com.mysql.cj.jdbc.ConnectionImpl@78e117e3]
9:com.mchange.v2.c3p0.impl.NewProxyConnection@4386f16 [wrapping: com.mysql.cj.jdbc.ConnectionImpl@363ee3a2]
10:com.mchange.v2.c3p0.impl.NewProxyConnection@79b06cab [wrapping: com.mysql.cj.jdbc.ConnectionImpl@3eb7fc54]
11:com.mchange.v2.c3p0.impl.NewProxyConnection@3c22fc4c [wrapping: com.mysql.cj.jdbc.ConnectionImpl@460d0a57]

Process finished with exit code 0
 

  相关解决方案