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


Java PGSimpleDataSource.setPortNumber方法代码示例

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


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

示例1: run

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
public boolean run(String host, int port,Socket tunnel) throws Exception {

    try {
        PGSimpleDataSource ds = new PGSimpleDataSource();
        ds.setServerName(host);
        ds.setPortNumber(port);
        ds.setSsl(true);
        ///this.sslContext = InstallCert.getContext();
        ds.setSslfactory(host);
        ds.setSslfactory(DumperFactory.class.getName());
        Connection c = ds.getConnection();
        c.close();
        return true;
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
    return false;
}
 
开发者ID:spyhunter99,项目名称:installcert,代码行数:20,代码来源:StarttlsHandlerPOSTGRES.java

示例2: postgreDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataSource postgreDataSource() {
    synchronized (LOCK) {
        if (dataSource == null) {
            final PGSimpleDataSource pgDataSource = new PGSimpleDataSource();

            pgDataSource.setServerName("localhost");
            pgDataSource.setPortNumber(5432);
            pgDataSource.setDatabaseName("iws");
            pgDataSource.setUser("iws_user");
            pgDataSource.setPassword("iws");

            dataSource = pgDataSource;
        }

        return dataSource;
    }
}
 
开发者ID:IWSDevelopers,项目名称:iws,代码行数:18,代码来源:SpringConfig.java

示例3: getDataSourceLocator

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
public SQLDataSourceLocator getDataSourceLocator() {
    return new SQLDataSourceLocator() {
        public DataSource lookup(SQLDataSetDef def) throws Exception {
            String server = connectionSettings.getProperty("server");
            String database = connectionSettings.getProperty("database");
            String port = connectionSettings.getProperty("port");
            String user = connectionSettings.getProperty("user");
            String password = connectionSettings.getProperty("password");

            PGSimpleDataSource ds = new PGSimpleDataSource();
            ds.setServerName(server);
            ds.setDatabaseName(database);
            ds.setPortNumber(Integer.parseInt(port));
            if (!StringUtils.isBlank(user)) {
                ds.setUser(user);
            }
            if (!StringUtils.isBlank(password)) {
                ds.setPassword(password);
            }
            return ds;
        }
    };
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:PostgresTestSettings.java

示例4: getDatabase

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public DataSource getDatabase(String userName, String dbName, Map<String, String> properties)
{
    final PGSimpleDataSource ds = new PGSimpleDataSource();
    ds.setServerName("localhost");
    ds.setPortNumber(port);
    ds.setDatabaseName(dbName);
    ds.setUser(userName);

    properties.forEach((propertyKey, propertyValue) -> {
        try {
            ds.setProperty(propertyKey, propertyValue);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    });
    return ds;
}
 
开发者ID:opentable,项目名称:otj-pg-embedded,代码行数:18,代码来源:EmbeddedPostgres.java

示例5: getConnection

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public Connection getConnection() throws IOException {
	PGSimpleDataSource dataSource = new PGSimpleDataSource();
	Properties dataSourceProperties = new Properties();
	dataSourceProperties.load(getClass().getResourceAsStream(
			"datasource-test.properties"));
	dataSource
			.setServerName(dataSourceProperties.getProperty("serverName"));
	dataSource.setDatabaseName(dataSourceProperties
			.getProperty("databaseName"));
	dataSource.setPortNumber(Integer.parseInt(dataSourceProperties
			.getProperty("portNumber")));
	dataSource.setUser(dataSourceProperties.getProperty("user"));
	dataSource.setPassword(dataSourceProperties.getProperty("password"));

	try {
		return dataSource.getConnection();
	} catch (Exception e) {
		IllegalArgumentException e1 = new IllegalArgumentException(
				"couldn't open database connection: " + e.getMessage());
		e1.initCause(e);
		throw e1;
	}

}
 
开发者ID:jotpe,项目名称:regio-osm,代码行数:25,代码来源:TestPostprocessing.java

示例6: preparePostgreSQL

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataSource preparePostgreSQL(final Settings settings) {
    try {
        final PGSimpleDataSource dataSource = new PGSimpleDataSource();

        dataSource.setServerName(settings.readDatabaseHost());
        dataSource.setPortNumber(Integer.parseInt(settings.readDatabasePort()));
        dataSource.setDatabaseName(settings.readDatabaseName());
        dataSource.setUser(settings.readDatabaseUsername());
        dataSource.setPassword(settings.readDatabasePassword());

        return dataSource;
    } catch (SecurityException e) {
        throw new LeargasException(e.getMessage(), e);
    }
}
 
开发者ID:IWSDevelopers,项目名称:iws,代码行数:16,代码来源:Leargas.java

示例7: getDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static PGSimpleDataSource getDataSource(IOTestPipelineOptions options)
    throws SQLException {
  PGSimpleDataSource dataSource = new PGSimpleDataSource();

  dataSource.setDatabaseName(options.getPostgresDatabaseName());
  dataSource.setServerName(options.getPostgresServerName());
  dataSource.setPortNumber(options.getPostgresPort());
  dataSource.setUser(options.getPostgresUsername());
  dataSource.setPassword(options.getPostgresPassword());
  dataSource.setSsl(options.getPostgresSsl());

  return dataSource;
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:JdbcIOIT.java

示例8: SurveyDatabase

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private SurveyDatabase(ServletConfig servletConfig) throws SQLException {
		dataSource = new PGSimpleDataSource();
        String dbName = System.getProperty("RDS_DB_NAME"); 
        //TODO: Find out why the environment variable is not taking for the DB
        // name in AWS - showing EBDB instead of what was set!
//        if (dbName == null) {
//        	logger.debug("Using servlet dbname");
        	dbName = servletConfig.getServletContext().getInitParameter("openchaindb_dbname");
//        }
        if (dbName == null) {
        	throw new SQLException("NO database configuration found");
        }
        dataSource.setDatabaseName(dbName);
        String userName = System.getProperty("RDS_USERNAME"); 
        if (userName == null) {
        	logger.debug("Using servlet dbuser");
        	userName = servletConfig.getServletContext().getInitParameter("openchaindb_user");
        }
        dataSource.setUser(userName);
        String password = System.getProperty("RDS_PASSWORD");
        if (password == null) {
        	logger.debug("Using servlet db password");
        	password = servletConfig.getServletContext().getInitParameter("openchaindb_password");
        }
        dataSource.setPassword(password);
        String hostname = System.getProperty("RDS_HOSTNAME");
        if (hostname == null) {
        	logger.debug("Using servlet dbhost name");
        	hostname = servletConfig.getServletContext().getInitParameter("openchaindb_server");
        }
        dataSource.setServerName(hostname);
        String port = System.getProperty("RDS_PORT");
        if (port == null) {
        	logger.debug("Using servlet dbport");
        	port = servletConfig.getServletContext().getInitParameter("openchaindb_port");
        }
        dataSource.setPortNumber(Integer.parseInt(port));
        logger.info("Database connection with database name "+dbName+
        		" on host" + hostname + "with user" + userName);
	}
 
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:41,代码来源:SurveyDatabase.java

示例9: createTestDataAccessProvider

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataAccessProvider createTestDataAccessProvider() {
    PGSimpleDataSource dataSource = new PGSimpleDataSource();

    dataSource.setServerName("localhost");
    dataSource.setPortNumber(5432);
    dataSource.setDatabaseName("rasbeb_test");
    dataSource.setUser("rasbeb_tester");
    dataSource.setPassword("test_password");

    return new JDBCDataAccessProvider(true, dataSource);
}
 
开发者ID:kcoolsae,项目名称:Rasbeb,代码行数:12,代码来源:JDBCDataAccess.java

示例10: actualDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
public DataSource actualDataSource() {
    PGSimpleDataSource dataSource = new PGSimpleDataSource();
    dataSource.setDatabaseName(jdbcDatabase);
    dataSource.setUser(jdbcUser);
    dataSource.setPassword(jdbcPassword);
    dataSource.setServerName(jdbcHost);
    dataSource.setPortNumber(Integer.valueOf(jdbcPort));
    return dataSource;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:11,代码来源:PostgreSQLJPAConfiguration.java

示例11: createDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
protected DataSource createDataSource() {
	PGSimpleDataSource source = new PGSimpleDataSource();
	source.setServerName(HOST);
	source.setDatabaseName(getRepositoryName()+"?searchpath=cdoserver"); //$NON-NLS-1$
	source.setUser(USER);
	source.setPassword(PASS);
	source.setPortNumber(PORT);
	return source;
}
 
开发者ID:opencanarias,项目名称:model-repository-benchmark,代码行数:10,代码来源:JVMPostgresCDOModelRepository.java

示例12: createDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
/**
 * Create a new database, and return it as a DataSource.
 * No two invocations will return the same database.
 */
public DataSource createDataSource() throws SQLException
{
    final DbInfo db = dbPreparer.getNextDb();
    final PGSimpleDataSource ds = new PGSimpleDataSource();
    ds.setPortNumber(db.port);
    ds.setDatabaseName(db.dbName);
    ds.setUser(db.user);
    return ds;
}
 
开发者ID:opentable,项目名称:otj-pg-embedded,代码行数:14,代码来源:PreparedDbProvider.java

示例13: dataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Bean(name = "sampledb")
public DataSource dataSource() {
    PGSimpleDataSource d = new PGSimpleDataSource();
    d.setServerName(host);
    d.setDatabaseName(databaseName);
    d.setPortNumber(portNumber);
    d.setUser(user);
    d.setPassword(password);
    return d;
}
 
开发者ID:vanioinformatika,项目名称:easydao,代码行数:11,代码来源:PostgresDataSourceConfig.java

示例14: getAdminDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override public DataSource getAdminDataSource()
{
	PGSimpleDataSource ds = new PGSimpleDataSource();
	ds.setServerName(this.getHostName());
	ds.setPortNumber(this.getPort());
	ds.setUser(this.getAdminUsername());
	ds.setPassword(this.getAdminPassword());
	ds.setDatabaseName("postgres");
	
	return ds;
}
 
开发者ID:mathesonventures,项目名称:wildebeest,代码行数:12,代码来源:PostgreSqlDatabaseInstance.java

示例15: getAppDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override public DataSource getAppDataSource()
{
	PGSimpleDataSource ds = new PGSimpleDataSource();
	ds.setServerName(this.getHostName());
	ds.setPortNumber(this.getPort());
	ds.setUser(this.getAdminUsername());
	ds.setPassword(this.getAdminPassword());
	ds.setDatabaseName(this.getDatabaseName().toLowerCase());
	
	return ds;
}
 
开发者ID:mathesonventures,项目名称:wildebeest,代码行数:12,代码来源:PostgreSqlDatabaseInstance.java


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