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


Java PGDataSource.setHost方法代码示例

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


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

示例1: setUp

import com.impossibl.postgres.jdbc.PGDataSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    this.host = System.getProperty("pgjdbc.test.server", "localhost");
    this.port = System.getProperty("pgjdbc.test.port", "5432");
    this.database = System.getProperty("pgjdbc.test.db", "event_tests");
    this.user = System.getProperty("pgjdbc.test.user", "dphillips");
    this.password = System.getProperty("pgjdbc.test.password");

    ds = new PGDataSource();
    ds.setHost(this.host);
    ds.setPort(Integer.parseInt(this.port));
    ds.setDatabase(this.database);
    ds.setUser(this.user);
    if (this.password != null) {
        ds.setPassword(this.password);
    }

    main = new Main();
    main.bind("test", ds);
    main.addRouteBuilder(buildConsumer());
    main.addRouteBuilder(buildProducer());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:IntegrationTest.java

示例2: startNotificationListener

import com.impossibl.postgres.jdbc.PGDataSource; //导入方法依赖的package包/类
@Override
public void startNotificationListener(DBMSSynchronizer dbmsSynchronizer) {
    // Disable cleanup output of ThreadedHousekeeper
    Logger.getLogger(ThreadedHousekeeper.class.getName()).setLevel(Level.SEVERE);

    this.listener = new PostgresSQLNotificationListener(dbmsSynchronizer);

    PGDataSource dataSource = new PGDataSource();
    dataSource.setHost(connectionProperties.getHost());
    dataSource.setPort(connectionProperties.getPort());
    dataSource.setDatabase(connectionProperties.getDatabase());
    dataSource.setUser(connectionProperties.getUser());
    dataSource.setPassword(connectionProperties.getPassword());

    try {
        pgConnection = (PGConnection) dataSource.getConnection();
        pgConnection.createStatement().execute("LISTEN jabrefLiveUpdate");
        // Do not use `new PostgresSQLNotificationListener(...)` as the object has to exist continuously!
        // Otherwise the listener is going to be deleted by GC.
        pgConnection.addNotificationListener(listener);
    } catch (SQLException e) {
        LOGGER.error("SQL Error: ", e);
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:25,代码来源:PostgreSQLProcessor.java

示例3: getPostgreSQLDataSource

import com.impossibl.postgres.jdbc.PGDataSource; //导入方法依赖的package包/类
@SneakyThrows
private static PGDataSource getPostgreSQLDataSource() {
    if (dataSource == null) {
        PGDataSource ds = new PGDataSource();
        ds.setHost("localhost");
        ds.setDatabase("foodsourcing");
        ds.setUser("foodsourcing");
        ds.setPassword("foodsourcing");
        ds.setHousekeeper(false);
    }

    return dataSource;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:14,代码来源:TestWithRepository.java

示例4: createDataSource

import com.impossibl.postgres.jdbc.PGDataSource; //导入方法依赖的package包/类
@SneakyThrows
public static PGDataSource createDataSource() {
    if (pgConfig == null) {
        pgConfig = launchPostgres();
    }

    PGDataSource ds = new PGDataSource();
    ds.setHost(pgConfig.net().host());
    ds.setDatabase(pgConfig.storage().dbName());
    ds.setUser(pgConfig.credentials().username());
    ds.setPassword(pgConfig.credentials().password());
    ds.setPort(pgConfig.net().port());
    ds.setHousekeeper(false);


    String databaseName = UUID.randomUUID().toString();

    try (Connection c = ds.getConnection()) {
        try (PreparedStatement preparedStatement = c.prepareStatement("CREATE DATABASE \"" + databaseName + "\"")) {
            preparedStatement.executeUpdate();
        }
    }

    ds.setDatabase(databaseName);

    return ds;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:28,代码来源:PostgreSQLTest.java

示例5: createJournal

import com.impossibl.postgres.jdbc.PGDataSource; //导入方法依赖的package包/类
@Override protected Journal createJournal() {
    PGDataSource ds = new PGDataSource();
    ds.setHost("localhost");
    ds.setDatabase("eventsourcing");
    ds.setUser("eventsourcing");
    ds.setPassword("eventsourcing");
    ds.setPort(System.getenv("PGPORT") == null ? 5432 : Integer.valueOf(System.getenv("PGPORT")));
    ds.setHousekeeper(false);

    HikariConfig config = new HikariConfig();
    config.setMaximumPoolSize(30);

    return new PostgreSQLJournal(ds, config);
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:15,代码来源:PostgreSQLRepositoryBenchmark.java


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