import com.jolbox.bonecp.BoneCP; import com.jolbox.bonecp.BoneCPConfig; public class ConnectionPoolExample { public static void main(String[] args) { BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl("jdbc:mysql://localhost/test"); config.setUsername("root"); config.setPassword("password"); try { BoneCP connectionPool = new BoneCP(config); Connection connection = connectionPool.getConnection(); // ... connection.close(); connectionPool.shutdown(); } catch (SQLException e) { e.printStackTrace(); } } } <dependency> <groupId>com.jolbox</groupId> <artifactId>bonecp</artifactId> <version>0.8.0.RELEASE</version> </dependency> properties bonecp.minConnectionsPerPartition=5 bonecp.maxConnectionsPerPartition=20 bonecp.connectionTimeout=5000 bonecp.idleMaxAge=1800000


上一篇:
下一篇:
切换中文