package DBBasic;

import java.sql.Connection;
import java.sql.SQLException;
import com.jolbox.bonecp.*;

public class ConnBasic{
	private static BoneCP connectionPool = null;
	public ConnBasic(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
			BoneCPConfig config = new BoneCPConfig();
			config.setJdbcUrl(UserPWmemory.getDBname()); 
			config.setUsername( UserPWmemory.getUser()); 
			config.setPassword(UserPWmemory.getPW());
			config.setMinConnectionsPerPartition(5);
			config.setMaxConnectionsPerPartition(10);
			config.setPartitionCount(1);
			try {
				connectionPool = new BoneCP(config);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				System.out.println(e.getMessage());
			}
		
	}
	public static Connection getconn() {
		Connection connection = null;
		try {
			connection = connectionPool.getConnection();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return connection;
	}
}

  需要一些外包BoneCP的简单使用

相关文章:

  • 2021-11-30
  • 2021-12-02
  • 2021-12-02
  • 2021-12-16
  • 2021-12-06
  • 2021-11-18
  • 2021-11-30
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-06-02
  • 2021-04-25
  • 2021-05-22
相关资源
相似解决方案