当前位置: 首页>>代码示例>>Java>>正文


Java PGPoolingDataSource.setInitialConnections方法代码示例

本文整理汇总了Java中org.postgresql.ds.PGPoolingDataSource.setInitialConnections方法的典型用法代码示例。如果您正苦于以下问题:Java PGPoolingDataSource.setInitialConnections方法的具体用法?Java PGPoolingDataSource.setInitialConnections怎么用?Java PGPoolingDataSource.setInitialConnections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.postgresql.ds.PGPoolingDataSource的用法示例。


在下文中一共展示了PGPoolingDataSource.setInitialConnections方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDataSource

import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
@Override
public DataSource getDataSource() {
    URI uri = getURIFromEnv();
    String host = uri.getHost();
    int port = uri.getPort();
    String db = uri.getPath().substring(1);
    String username = uri.getUserInfo().split(":")[0];
    String password = uri.getUserInfo().split(":")[1];

    PGPoolingDataSource ds = new PGPoolingDataSource();
    ds.setSsl(true);
    ds.setSslMode("verify-full");
    ds.setUser(username);
    ds.setServerName(host);
    ds.setPortNumber(port);
    ds.setPassword(password);
    ds.setDatabaseName(db);
    ds.setInitialConnections(0);
    Integer maxConnections = getMaxConnectionsFromEnv();
    if(maxConnections != null)
        ds.setMaxConnections(maxConnections);
    return ds;
}
 
开发者ID:Exorath,项目名称:ServiceCommons,代码行数:24,代码来源:EnvironmentPGProvider.java

示例2: lookup

import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
private DataSource lookup( String name )
{
    Configuration map = configurationService.getConfiguration( name );

    PGPoolingDataSource ds = new PGPoolingDataSource();
    ds.setApplicationName( "OpenData" );
    ds.setDataSourceName( map.getString( "name", () -> map.getString( "database" ) ) );
    ds.setMaxConnections( map.getInt( "connections.max", 10 ) );
    ds.setInitialConnections( map.getInt( "connections.initial", 0 ) );

    ds.setUser( Objects.requireNonNull( map.getString( "username" ), "username required" ) );
    ds.setPassword( Objects.requireNonNull( map.getString( "password" ), "password required" ) );
    ds.setServerName( Objects.requireNonNull( map.getString( "hostname" ), "hostname required" ) );
    ds.setDatabaseName( map.getString( "database", () -> map.getString( "name" ) ) );
    ds.setPortNumber( map.getInt( "port", 0 ) );

    return ds;
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:19,代码来源:DataSourceProducer.java

示例3: PostgresqlConnectionProvider

import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
public PostgresqlConnectionProvider(@NonNls @NotNull final String serverDnsHostName, @NonNls @NotNull final String databaseName, @NonNls @NotNull final String applicationName, @NonNls @NotNull final String userName, @NonNls @NotNull final String password)
{
	dataSource = new PGPoolingDataSource();
	dataSource.setDataSourceName(randomUUID().toString());
	dataSource.setInitialConnections(2);
	dataSource.setMaxConnections(10);

	dataSource.setServerName(serverDnsHostName);
	dataSource.setPortNumber(DefaultPostgresPort);
	dataSource.setTcpKeepAlive(true);
	dataSource.setSocketTimeout(ThirtySeconds);

	dataSource.setSsl(false);
	dataSource.setProtocolVersion(0);
	dataSource.setSendBufferSize(FourKilobytes);
	dataSource.setReceiveBufferSize(FourKilobytes);
	dataSource.setBinaryTransfer(true);

	dataSource.setDatabaseName(databaseName);
	dataSource.setApplicationName(applicationName);
	dataSource.setUser(userName);
	dataSource.setPassword(password);
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:24,代码来源:PostgresqlConnectionProvider.java

示例4: 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;
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:16,代码来源:Chapter06Database01.java

示例5: dataSource

import org.postgresql.ds.PGPoolingDataSource; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
  DataSource dataSource(Environment env) throws IllegalStateException, SQLException { 

      PGPoolingDataSource pgPoolingDataSource = new PGPoolingDataSource();
      pgPoolingDataSource.setUrl(env.getRequiredProperty("db.url"));
      pgPoolingDataSource.setUser(env.getRequiredProperty("db.username"));
      pgPoolingDataSource.setPassword(env.getRequiredProperty("db.password"));
      pgPoolingDataSource.setInitialConnections(Integer.parseInt(env.getRequiredProperty("db.pool_size")));
return pgPoolingDataSource;
  }
 
开发者ID:dgalaktionov,项目名称:RIE-Model,代码行数:11,代码来源:PersistenceContext.java


注:本文中的org.postgresql.ds.PGPoolingDataSource.setInitialConnections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。