本文整理汇总了Java中org.postgresql.ds.PGSimpleDataSource.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Java PGSimpleDataSource.setUrl方法的具体用法?Java PGSimpleDataSource.setUrl怎么用?Java PGSimpleDataSource.setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.ds.PGSimpleDataSource
的用法示例。
在下文中一共展示了PGSimpleDataSource.setUrl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataSources
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Parameters(name = "{index}:{0}")
public static Collection<DataSource> getDataSources() {
List<DataSource> dataSources = new ArrayList<>();
dataSources.add(newH2DataSource());
// MySQL
if (HekateTestProps.is("MYSQL_ENABLED")) {
MysqlDataSource mysql = new MysqlDataSource();
mysql.setURL(HekateTestProps.get("MYSQL_URL"));
mysql.setUser(HekateTestProps.get("MYSQL_USER"));
mysql.setPassword(HekateTestProps.get("MYSQL_PASSWORD"));
dataSources.add(mysql);
}
// PostgreSQL
if (HekateTestProps.is("POSTGRES_ENABLED")) {
PGSimpleDataSource postgres = new PGSimpleDataSource();
postgres.setUrl(HekateTestProps.get("POSTGRES_URL"));
postgres.setUser(HekateTestProps.get("POSTGRES_USER"));
postgres.setPassword(HekateTestProps.get("POSTGRES_PASSWORD"));
dataSources.add(postgres);
}
return dataSources;
}
示例2: withPosgresSimpleDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private DataSource withPosgresSimpleDataSource() {
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setUrl(String.format("jdbc:postgresql://%s:%s/%s", hostname, port, database));
ds.setUser(username);
ds.setPassword(password);
return ds;
}
示例3: createPGDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public static PGSimpleDataSource createPGDataSource(String connString, String connUser, String connPassword) {
PGSimpleDataSource source = new PGSimpleDataSource();
source.setUrl(connString);
source.setUser(connUser);
source.setPassword(connPassword);
return source;
}
示例4: configure
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
protected void configure() {
final Map<String, String> properties = new HashMap<>();
properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
properties.put(JDBC_URL, dbUrl);
properties.put(JDBC_USER, dbUser);
properties.put(JDBC_PASSWORD, dbPassword);
properties.put(JDBC_DRIVER, System.getProperty("jdbc.driver"));
JpaPersistModule main = new JpaPersistModule("main");
main.properties(properties);
install(main);
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class)
.toInstance(new FlywaySchemaInitializer(dataSource, "che-schema", "codenvy-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
bind(new TypeLiteral<TckRepository<InviteImpl>>() {})
.toInstance(new JpaTckRepository<>(InviteImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {})
.toInstance(new JpaTckRepository<>(OrganizationImpl.class));
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {})
.toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(InviteDao.class).to(JpaInviteDao.class);
}
示例5: INIT
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public static synchronized void INIT() {
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setUrl(PG_URL);
try (final Connection cnx = ds.getConnection(); final Statement st = cnx.createStatement()) {
st.execute(TestSuite.getResourceAsString(PG_SQL));
} catch (Exception ex) {
throw new RuntimeException(ex);
}
TestSuite.setupSessionFactoryBuilder(ds);
}
示例6: prepareTestingDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public static DataSource prepareTestingDataSource() {
PGSimpleDataSource source = new PGSimpleDataSource();
source.setUrl("jdbc:postgresql://localhost:5432/pivots_test");
return source;
}
示例7: buildDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private DataSource buildDataSource() {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUrl("jdbc:postgresql://localhost/example_test");
return dataSource;
}
示例8: init
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws SQLException, IOException {
PGSimpleDataSource pgDs = new PGSimpleDataSource();
pgDs.setUrl(PG_URL);
sessionFactory = JsonHandlersTestApi.setUpDb(pgDs, PG_SQL);
}