use of org.postgresql.ds.PGSimpleDataSource in project aroma-data-operations by RedRoma.
the class ModuleTesting method provideDataSource.
@Provides
DataSource provideDataSource() throws MalformedURLException, SQLException {
String url = createProductionTestConnection();
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUrl(url);
try (Connection conn = dataSource.getConnection()) {
System.out.println("Connected");
}
return dataSource;
}
use of org.postgresql.ds.PGSimpleDataSource in project torodb by torodb.
the class OfficialPostgreSqlDriver method getConfiguredDataSource.
@Override
public DataSource getConfiguredDataSource(PostgreSqlBackendConfiguration configuration, String poolName) {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(configuration.getUsername());
dataSource.setPassword(configuration.getPassword());
dataSource.setServerName(configuration.getDbHost());
dataSource.setPortNumber(configuration.getDbPort());
dataSource.setDatabaseName(configuration.getDbName());
dataSource.setApplicationName("torodb-" + poolName);
if (JDBC_LOGGER.isTraceEnabled()) {
dataSource.setLogLevel(Driver.DEBUG);
dataSource.setLogWriter(LOGGER_WRITER);
}
try (Connection conn = dataSource.getConnection();
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT 1")) {
rs.next();
} catch (SQLException ex) {
throw new SystemException(ex.getLocalizedMessage());
}
return dataSource;
}
use of org.postgresql.ds.PGSimpleDataSource in project spring-data-jdbc by spring-projects.
the class PostgresDataSourceConfiguration method createDataSource.
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
*/
@Override
protected DataSource createDataSource() {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUrl(POSTGRESQL_CONTAINER.getJdbcUrl());
dataSource.setUser(POSTGRESQL_CONTAINER.getUsername());
dataSource.setPassword(POSTGRESQL_CONTAINER.getPassword());
return dataSource;
}
use of org.postgresql.ds.PGSimpleDataSource in project sis by apache.
the class MetadataWriterTest method testPostgreSQL.
/**
* Runs all tests on PostgreSQL in the required order. This test is disabled by default
* because it requires manual setup of a test database.
*
* @throws Exception if an error occurred while writing or reading the database.
*/
@Test
@Ignore("This test need to be run manually on a machine having a local PostgreSQL database.")
public void testPostgreSQL() throws Exception {
final PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName("localhost");
ds.setDatabaseName("SpatialMetadataTest");
source = new MetadataWriter(MetadataStandard.ISO_19115, ds, "metadata", null);
try {
write();
search();
read();
readWriteDeprecated();
} finally {
source.close();
}
}
use of org.postgresql.ds.PGSimpleDataSource in project sis by apache.
the class EPSGInstallerTest method testCreationOnPostgreSQL.
/**
* Tests the creation of an EPSG database on PostgreSQL. This test is disabled by default.
* To run this test, the tester needs to launch on {@code "localhost"} a PostgreSQL server
* having an empty database named {@code "SpatialMetadataTest"}. After the test completion,
* one can verify the {@code "EPSG"} schema created by the test, then delete that schema for future test executions
* (this test does <strong>not</strong> delete by itself the schema that it created).
*
* @throws Exception if an error occurred while creating the database.
*
* @since 0.8
*/
@Test
@Ignore("This test need to be run manually on a machine having a local PostgreSQL database.")
public void testCreationOnPostgreSQL() throws Exception {
// Needs to be invoked first.
final InstallationScriptProvider scripts = getScripts();
final PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName("localhost");
ds.setDatabaseName("SpatialMetadataTest");
createAndTest(ds, scripts);
loggings.assertNextLogContains("EPSG", "jdbc:postgresql://localhost/SpatialMetadataTest");
loggings.assertNoUnexpectedLog();
}
Aggregations