import com.jolbox.bonecp.BoneCP;
import com.jolbox.bonecp.BoneCPConfig;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class BoneCPExample {
private static BoneCP connectionPool;
public static void main(String[] args) {
try {
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/mydb");
config.setUsername("username");
config.setPassword("password");
config.setMinConnectionsPerPartition(5);
config.setMaxConnectionsPerPartition(10);
connectionPool = new BoneCP(config);
Connection connection = connectionPool.getConnection();
String sql = "SELECT * FROM users";
PreparedStatement statement = connection.prepareStatement(sql);
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
String username = resultSet.getString("username");
System.out.println("Username: " + username);
}
resultSet.close();
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (connectionPool != null) {
connectionPool.close();
}
}
}
}