c3p0数据库使用

1.导入相关jar
在这里插入图片描述

1.编写c3p0-config.xml
在这里插入图片描述

  // 创建c3p0连接池核心工具类
	// 自动加载src下c3p0的配置文件【c3p0-config.xml】
	ComboPooledDataSource dataSource = new ComboPooledDataSource();// 使用默认的配置
	PreparedStatement pstmt = null;
	// 获取连接
	Connection con = dataSource.getConnection();
	for (int i=1; i<100;i++){
		String sql = "insert into  ee set name='11'";
		// 执行更新
		pstmt = con.prepareStatement(sql);
		pstmt.executeUpdate();
	}
	pstmt.close();
	// 关闭
	con.close();

猜你喜欢

转载自blog.csdn.net/qq_41740138/article/details/82814225