Java Code Examples for org.postgresql.ds.PGSimpleDataSource#setUrl()

The following examples show how to use org.postgresql.ds.PGSimpleDataSource#setUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostgresDataSourceFactory.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: Postgres10DataSourceFactory.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 3
Source File: JpaIntegrationTckModule.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: PostgresqlSuite.java    From mybatis-types with MIT License 5 votes vote down vote up
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);
    }
 
Example 5
Source File: PostgresqlTest.java    From mybatis-jackson with MIT License 4 votes vote down vote up
@BeforeClass
public static void init() throws SQLException, IOException {
    PGSimpleDataSource pgDs = new PGSimpleDataSource();
    pgDs.setUrl(PG_URL);
    sessionFactory = JsonHandlersTestApi.setUpDb(pgDs, PG_SQL);
}
 
Example 6
Source File: PostgresqlTest.java    From mybatis-gson with MIT License 4 votes vote down vote up
@BeforeClass
public static void init() throws SQLException, IOException {
    PGSimpleDataSource pgDs = new PGSimpleDataSource();
    pgDs.setUrl(PG_URL);
    sessionFactory = JsonHandlersTestApi.setUpDb(pgDs, PG_SQL);
}
 
Example 7
Source File: MultiuserPostgresqlTckModule.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@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"));
  bind(DBInitializer.class).asEagerSingleton();
  bind(TckResourcesCleaner.class).to(JpaCleaner.class);

  // repositories
  // api-account
  bind(new TypeLiteral<TckRepository<AccountImpl>>() {})
      .toInstance(new JpaTckRepository<>(AccountImpl.class));
  // api-user
  bind(new TypeLiteral<TckRepository<UserImpl>>() {}).to(UserJpaTckRepository.class);

  // api-workspace
  bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {})
      .toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
  bind(new TypeLiteral<TckRepository<WorkerImpl>>() {})
      .toInstance(new JpaTckRepository<>(WorkerImpl.class));

  // api permission
  bind(new TypeLiteral<TckRepository<SystemPermissionsImpl>>() {})
      .toInstance(new JpaTckRepository<>(SystemPermissionsImpl.class));

  bind(new TypeLiteral<PermissionsDao<SystemPermissionsImpl>>() {})
      .to(JpaSystemPermissionsDao.class);

  bind(new TypeLiteral<AbstractPermissionsDomain<WorkerImpl>>() {})
      .to(WorkerDaoTest.TestDomain.class);
  bind(new TypeLiteral<AbstractPermissionsDomain<SystemPermissionsImpl>>() {})
      .to(SystemPermissionsDaoTest.TestDomain.class);

  // api-organization
  bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {})
      .to(JpaOrganizationImplTckRepository.class);
  bind(new TypeLiteral<TckRepository<MemberImpl>>() {})
      .toInstance(new JpaTckRepository<>(MemberImpl.class));
  bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {})
      .toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));

  // api-resource
  bind(new TypeLiteral<TckRepository<FreeResourcesLimitImpl>>() {})
      .toInstance(new JpaTckRepository<>(FreeResourcesLimitImpl.class));

  // machine token keys
  bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {})
      .toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));

  // dao
  bind(OrganizationDao.class).to(JpaOrganizationDao.class);
  bind(OrganizationDistributedResourcesDao.class)
      .to(JpaOrganizationDistributedResourcesDao.class);
  bind(FreeResourcesLimitDao.class).to(JpaFreeResourcesLimitDao.class);

  bind(WorkerDao.class).to(JpaWorkerDao.class);
  bind(MemberDao.class).to(JpaMemberDao.class);
  bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
  bind(new TypeLiteral<PermissionsDao<MemberImpl>>() {}).to(JpaMemberDao.class);
  bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {}).to(OrganizationDomain.class);

  // SHA-512 ecnryptor is faster than PBKDF2 so it is better for testing
  bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class).in(Singleton.class);

  // Creates empty multibinder to avoid error during container starting
  Multibinder.newSetBinder(
      binder(), String.class, Names.named(SystemDomain.SYSTEM_DOMAIN_ACTIONS));
}