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


Java PGSimpleDataSource.setUser方法代码示例

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


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

示例1: postgreDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataSource postgreDataSource() {
    synchronized (LOCK) {
        if (dataSource == null) {
            final PGSimpleDataSource pgDataSource = new PGSimpleDataSource();

            pgDataSource.setServerName("localhost");
            pgDataSource.setPortNumber(5432);
            pgDataSource.setDatabaseName("iws");
            pgDataSource.setUser("iws_user");
            pgDataSource.setPassword("iws");

            dataSource = pgDataSource;
        }

        return dataSource;
    }
}
 
开发者ID:IWSDevelopers,项目名称:iws,代码行数:18,代码来源:SpringConfig.java

示例2: getDataSourceLocator

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
public SQLDataSourceLocator getDataSourceLocator() {
    return new SQLDataSourceLocator() {
        public DataSource lookup(SQLDataSetDef def) throws Exception {
            String server = connectionSettings.getProperty("server");
            String database = connectionSettings.getProperty("database");
            String port = connectionSettings.getProperty("port");
            String user = connectionSettings.getProperty("user");
            String password = connectionSettings.getProperty("password");

            PGSimpleDataSource ds = new PGSimpleDataSource();
            ds.setServerName(server);
            ds.setDatabaseName(database);
            ds.setPortNumber(Integer.parseInt(port));
            if (!StringUtils.isBlank(user)) {
                ds.setUser(user);
            }
            if (!StringUtils.isBlank(password)) {
                ds.setPassword(password);
            }
            return ds;
        }
    };
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:PostgresTestSettings.java

示例3: getDatabase

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
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;
}
 
开发者ID:opentable,项目名称:otj-pg-embedded,代码行数:18,代码来源:EmbeddedPostgres.java

示例4: main

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public static void main( final String[] args) {
	System.out.println( "------------ starting tests --------------------\n");
	final PGSimpleDataSource ds= new PGSimpleDataSource();
	ds.setDatabaseName( "reporting");
	ds.setServerName( "127.0.0.1");
	ds.setUser( "reporting");
	ds.setPassword( "reporting");

	doResultTest( ds);
	//testQueryAllCols( ds);
	testQueryCount( ds);
	testGroupCount( ds);
	testWhereIn( ds);
	testSubselect( ds);

	doResultTestGC( ds);

	testInsertUpdate();

	queryTest();

	System.out.println( "\n------------ finished tests --------------------");

}
 
开发者ID:freiheit-com,项目名称:sqlapi4j,代码行数:25,代码来源:SqlApiTest.java

示例5: getConnection

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
public Connection getConnection() throws IOException {
	PGSimpleDataSource dataSource = new PGSimpleDataSource();
	Properties dataSourceProperties = new Properties();
	dataSourceProperties.load(getClass().getResourceAsStream(
			"datasource-test.properties"));
	dataSource
			.setServerName(dataSourceProperties.getProperty("serverName"));
	dataSource.setDatabaseName(dataSourceProperties
			.getProperty("databaseName"));
	dataSource.setPortNumber(Integer.parseInt(dataSourceProperties
			.getProperty("portNumber")));
	dataSource.setUser(dataSourceProperties.getProperty("user"));
	dataSource.setPassword(dataSourceProperties.getProperty("password"));

	try {
		return dataSource.getConnection();
	} catch (Exception e) {
		IllegalArgumentException e1 = new IllegalArgumentException(
				"couldn't open database connection: " + e.getMessage());
		e1.initCause(e);
		throw e1;
	}

}
 
开发者ID:jotpe,项目名称:regio-osm,代码行数:25,代码来源:TestPostprocessing.java

示例6: 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;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:31,代码来源:JdbcSeedNodeProviderTest.java

示例7: 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;
}
 
开发者ID:carlomorelli,项目名称:muon-app,代码行数:8,代码来源:DataSourceFactory.java

示例8: postgresDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataSource postgresDataSource() {
    final PGSimpleDataSource dataSource = new PGSimpleDataSource();

    dataSource.setServerName("localhost");
    dataSource.setDatabaseName("iws");
    dataSource.setUser("iws_user");
    dataSource.setPassword("iws");

    return dataSource;
}
 
开发者ID:IWSDevelopers,项目名称:iws,代码行数:11,代码来源:Beans.java

示例9: preparePostgreSQL

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataSource preparePostgreSQL(final Settings settings) {
    try {
        final PGSimpleDataSource dataSource = new PGSimpleDataSource();

        dataSource.setServerName(settings.readDatabaseHost());
        dataSource.setPortNumber(Integer.parseInt(settings.readDatabasePort()));
        dataSource.setDatabaseName(settings.readDatabaseName());
        dataSource.setUser(settings.readDatabaseUsername());
        dataSource.setPassword(settings.readDatabasePassword());

        return dataSource;
    } catch (SecurityException e) {
        throw new LeargasException(e.getMessage(), e);
    }
}
 
开发者ID:IWSDevelopers,项目名称:iws,代码行数:16,代码来源:Leargas.java

示例10: 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;
}
 
开发者ID:Remper,项目名称:sociallink,代码行数:8,代码来源:DBUtils.java

示例11: getDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static PGSimpleDataSource getDataSource(IOTestPipelineOptions options)
    throws SQLException {
  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;
}
 
开发者ID:apache,项目名称:beam,代码行数:14,代码来源:JdbcIOIT.java

示例12: 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);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:38,代码来源:JpaIntegrationTckModule.java

示例13: SurveyDatabase

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private SurveyDatabase(ServletConfig servletConfig) throws SQLException {
		dataSource = new PGSimpleDataSource();
        String dbName = System.getProperty("RDS_DB_NAME"); 
        //TODO: Find out why the environment variable is not taking for the DB
        // name in AWS - showing EBDB instead of what was set!
//        if (dbName == null) {
//        	logger.debug("Using servlet dbname");
        	dbName = servletConfig.getServletContext().getInitParameter("openchaindb_dbname");
//        }
        if (dbName == null) {
        	throw new SQLException("NO database configuration found");
        }
        dataSource.setDatabaseName(dbName);
        String userName = System.getProperty("RDS_USERNAME"); 
        if (userName == null) {
        	logger.debug("Using servlet dbuser");
        	userName = servletConfig.getServletContext().getInitParameter("openchaindb_user");
        }
        dataSource.setUser(userName);
        String password = System.getProperty("RDS_PASSWORD");
        if (password == null) {
        	logger.debug("Using servlet db password");
        	password = servletConfig.getServletContext().getInitParameter("openchaindb_password");
        }
        dataSource.setPassword(password);
        String hostname = System.getProperty("RDS_HOSTNAME");
        if (hostname == null) {
        	logger.debug("Using servlet dbhost name");
        	hostname = servletConfig.getServletContext().getInitParameter("openchaindb_server");
        }
        dataSource.setServerName(hostname);
        String port = System.getProperty("RDS_PORT");
        if (port == null) {
        	logger.debug("Using servlet dbport");
        	port = servletConfig.getServletContext().getInitParameter("openchaindb_port");
        }
        dataSource.setPortNumber(Integer.parseInt(port));
        logger.info("Database connection with database name "+dbName+
        		" on host" + hostname + "with user" + userName);
	}
 
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:41,代码来源:SurveyDatabase.java

示例14: createTestDataAccessProvider

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static DataAccessProvider createTestDataAccessProvider() {
    PGSimpleDataSource dataSource = new PGSimpleDataSource();

    dataSource.setServerName("localhost");
    dataSource.setPortNumber(5432);
    dataSource.setDatabaseName("rasbeb_test");
    dataSource.setUser("rasbeb_tester");
    dataSource.setPassword("test_password");

    return new JDBCDataAccessProvider(true, dataSource);
}
 
开发者ID:kcoolsae,项目名称:Rasbeb,代码行数:12,代码来源:JDBCDataAccess.java

示例15: actualDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@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;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:11,代码来源:PostgreSQLJPAConfiguration.java


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