本文整理汇总了Java中org.postgresql.ds.PGPoolingDataSource.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Java PGPoolingDataSource.getConnection方法的具体用法?Java PGPoolingDataSource.getConnection怎么用?Java PGPoolingDataSource.getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.ds.PGPoolingDataSource
的用法示例。
在下文中一共展示了PGPoolingDataSource.getConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConnectionPool
import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
@Test
public void createConnectionPool() throws SQLException {
PGPoolingDataSource connectionPool = new PGPoolingDataSource();
connectionPool.setApplicationName(CONFIG.DB_SERVER_NAME);
connectionPool.setServerName(CONFIG.DB_SERVER_NAME);
connectionPool.setPortNumber(CONFIG.DB_PORT_NUMBER);
connectionPool.setDatabaseName(CONFIG.DB_NAME);
connectionPool.setUser(CONFIG.DB_USER);
connectionPool.setPassword(CONFIG.DB_PASSWORD);
connectionPool.setMaxConnections(CONFIG.DB_MAX_CONNECTIONS);
Connection c = connectionPool.getConnection();
// request id for user dola with mode 1
CallableStatement s = c.prepareCall("{ ? = call request_id( ? , ? ) }");
s.registerOutParameter(1, Types.INTEGER);
s.setString(2, "blubbedi");
s.setInt(3, 1);
s.execute();
Integer client_id = s.getInt(1);
s.close();
assertNotNull("returned client id is null", client_id);
}
示例2: getDbConnection
import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
public static Connection getDbConnection(){
PGPoolingDataSource source = new PGPoolingDataSource();
source.setServerName("localhost");
source.setDatabaseName("cookbook");
source.setLoginTimeout(10);
try {
return source.getConnection();
}
catch(Exception ex) {
ex.printStackTrace();
return null;
}
}
示例3: getDbConnection
import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
private static Connection getDbConnection(){
PGPoolingDataSource source = new PGPoolingDataSource();
source.setServerName("localhost");
source.setDatabaseName("cookbook");
source.setInitialConnections(3);
source.setMaxConnections(10);
source.setLoginTimeout(10);
try {
return source.getConnection();
}
catch(Exception ex) {
ex.printStackTrace();
return null;
}
}
示例4: getDbConnection
import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
private static Connection getDbConnection(){
PGPoolingDataSource source = new PGPoolingDataSource();
source.setServerName("localhost");
source.setDatabaseName("cookbook");
try {
return source.getConnection();
}
catch(Exception ex) {
ex.printStackTrace();
return null;
}
}