@Override protected DataSource createDataSource() { final PGSimpleDataSource datasource = new PGSimpleDataSource(); datasource.setServerName(hostname); datasource.setPortNumber(port); datasource.setUser(username); datasource.setPassword(password); datasource.setDatabaseName(database); datasource.setApplicationName("Hermes Unit Tests"); return datasource; }
/** Returns a data source for the PostgreSQL database. */ protected DataSource createDataSource() throws SQLException { DataSource candidate = super.createDataSource(); if (candidate instanceof BaseDataSource) { // Any kind of DataSource from the PostgreSQL driver. return candidate; } final PGSimpleDataSource source = new PGSimpleDataSource(); final Properties p = load(); int portNumber; try { portNumber = Integer.parseInt(p.getProperty("portNumber", "5432")); } catch (NumberFormatException exception) { portNumber = 5432; Logging.unexpectedException( "org.geotools.referencing.factory", DataSource.class, "<init>", exception); } source.setPortNumber(portNumber); source.setServerName(p.getProperty("serverName", "localhost")); source.setDatabaseName(p.getProperty("databaseName", "EPSG")); source.setUser(p.getProperty("user", "Geotools")); source.setPassword(p.getProperty("password", "Geotools")); source.setProperty("stringtype", "unspecified"); schema = p.getProperty("schema", null); return source; }
/** * Returns a connection to the specified database with autocommit on. * * @param host_name * @param database * @return * @throws SQLException */ public synchronized Connection getConnection(final String host_name, final String database) throws SQLException { data_source.setDatabaseName(database); data_source.setServerName(host_name); return data_source.getConnection(); }
/** * Returns a connection to the specified database with autocommit on. * * @param host_name * @param database * @param user * @param password * @return * @throws SQLException */ public synchronized Connection getConnection(final String host_name, final String database, final String user, final String password) throws SQLException { data_source.setDatabaseName(database); data_source.setServerName(host_name); return data_source.getConnection(user, password); } }
dataSource.setServerName(servername); dataSource.setPortNumber(5432); dataSource.setDatabaseName(databaseName);
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; }
dataSourceBean.setServerName(hostName); dataSourceBean.setUser(userName); dataSourceBean.setPassword(passWord);
/** * Gets the connection parameters to the coverage database. */ private static DataSource getCoverageDataSource() throws IOException { final File pf = Installation.TESTS.directory(true).resolve("coverage-sql.properties").toFile(); assumeTrue(pf.isFile()); // The test will be skipped if the above resource is not found. final Properties properties = new Properties(); try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(pf))) { properties.load(in); } final PGSimpleDataSource ds = new PGSimpleDataSource(); ds.setServerName (properties.getProperty("server")); ds.setDatabaseName(properties.getProperty("database")); ds.setUser (properties.getProperty("user")); ds.setPassword (properties.getProperty("password")); return ds; }
pgSimpleDataSource.setBinaryTransfer(true); pgSimpleDataSource.setApplicationName("geogig"); pgSimpleDataSource.setServerName(connInfo.server); pgSimpleDataSource.setDatabaseName(connInfo.databaseName); pgSimpleDataSource.setPortNumber(connInfo.portNumber);
protected DataSource createDataSource(HostAndPort bindingHostAndPort) { PGSimpleDataSource ds = new PGSimpleDataSource(); ds.setPortNumber(bindingHostAndPort.getPort()); ds.setServerName(bindingHostAndPort.getHost()); ds.setUser(config.getUsername()); ds.setPassword(config.getPassword()); ds.setDatabaseName(config.getDb()); ds.setSsl(false); try ( Connection conn = ds.getConnection(); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery("SELECT 1")) { rs.next(); } catch (SQLException ex) { throw new RuntimeException(ex.getLocalizedMessage()); } return ds; }
private static PGSimpleDataSource createTestDataSource() throws SQLException { PGSimpleDataSource ds = new PGSimpleDataSource(); ds.setServerName("localhost"); ds.setDatabaseName("jdbcstoretest"); ds.setPortNumber(5432); ds.setUser("jdbcstore"); ds.setPassword("jdbcstore"); // Ensure the database is empty try (Connection conn = ds.getConnection()) { try (Statement stmt = conn.createStatement()) { stmt.execute("DROP SCHEMA IF EXISTS public CASCADE;"); stmt.execute("CREATE SCHEMA public;"); stmt.execute("GRANT ALL ON SCHEMA public TO postgres;"); stmt.execute("GRANT ALL ON SCHEMA public TO public;"); stmt.execute("COMMENT ON SCHEMA public IS 'standard public schema';"); } } return ds; }
dataSource.setServerName(configuration.getDbHost()); dataSource.setPortNumber(configuration.getDbPort()); dataSource.setDatabaseName(configuration.getDbName());
Database() { data_source = new PGSimpleDataSource(); data_source.setServerName(Config.INSTANCE.db_host); data_source.setPortNumber(Config.INSTANCE.db_port); data_source.setDatabaseName(Config.INSTANCE.db_database); data_source.setUser(Config.INSTANCE.db_user); data_source.setPassword(Config.INSTANCE.db_password); data_source.setApplicationName("jpgAgent: " + Config.INSTANCE.hostname); if (Config.INSTANCE.disable_prepared_statement) { data_source.setPreparedStatementCacheQueries(0); } }
@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; }
@Override public DataSource dataSource() { PGSimpleDataSource dataSource = new PGSimpleDataSource(); dataSource.setDatabaseName("high_performance_java_persistence"); dataSource.setServerName("localhost"); dataSource.setUser("postgres"); dataSource.setPassword("admin"); return dataSource; }
assumeTrue("Extensive tests not enabled.", TestCase.RUN_EXTENSIVE_TESTS); final PGSimpleDataSource ds = new PGSimpleDataSource(); ds.setServerName("localhost"); ds.setDatabaseName(NAME); ds.setApplicationName("Apache SIS test database");
@Ignore @Test public void testPostgres() throws Exception { PGSimpleDataSource dataSource = new PGSimpleDataSource(); dataSource.setPortNumber(5432); dataSource.setUser("sa"); dataSource.setPassword("sa"); dataSource.setServerName("localhost"); dataSource.setDatabaseName("commitmarkableresource"); doTest(dataSource); }
@Override public DataSource dataSource() { PGSimpleDataSource dataSource = new PGSimpleDataSource(); dataSource.setDatabaseName( "high_performance_java_persistence" ); dataSource.setServerName( host() ); dataSource.setPortNumber( port() ); dataSource.setUser( username() ); dataSource.setPassword( password() ); dataSource.setSsl( false ); return dataSource; }
private void addTenantConnectionProvider(String tenantId) { PGSimpleDataSource defaultDataSource = (PGSimpleDataSource) database().dataSourceProvider().dataSource(); Properties properties = properties(); PGSimpleDataSource tenantDataSource = new PGSimpleDataSource(); tenantDataSource.setDatabaseName(defaultDataSource.getDatabaseName()); tenantDataSource.setCurrentSchema(tenantId); tenantDataSource.setServerName(defaultDataSource.getServerName()); tenantDataSource.setUser(defaultDataSource.getUser()); tenantDataSource.setPassword(defaultDataSource.getPassword()); properties.put( Environment.DATASOURCE, dataSourceProxyType().dataSource(tenantDataSource) ); addTenantConnectionProvider(tenantId, tenantDataSource, properties); }
public static PGSimpleDataSource getPostgresDataSource(PostgresIOTestPipelineOptions options) { 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; }