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


Java PGSimpleDataSource.setServerName方法代码示例

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


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

示例1: run

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override
public boolean run(String host, int port,Socket tunnel) throws Exception {

    try {
        PGSimpleDataSource ds = new PGSimpleDataSource();
        ds.setServerName(host);
        ds.setPortNumber(port);
        ds.setSsl(true);
        ///this.sslContext = InstallCert.getContext();
        ds.setSslfactory(host);
        ds.setSslfactory(DumperFactory.class.getName());
        Connection c = ds.getConnection();
        c.close();
        return true;
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }
    return false;
}
 
开发者ID:spyhunter99,项目名称:installcert,代码行数:20,代码来源:StarttlsHandlerPOSTGRES.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getDbConnection2

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
private static Connection getDbConnection2(){
    PGSimpleDataSource source = new PGSimpleDataSource();
    source.setServerName("localhost");
    source.setDatabaseName("cookbook");
    source.setLoginTimeout(10);
    try {
        return source.getConnection();
    }
    catch(Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:14,代码来源:Chapter06Database01.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: 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

示例11: 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

示例12: 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

示例13: 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

示例14: createDataSource

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
protected DataSource createDataSource() {
	PGSimpleDataSource source = new PGSimpleDataSource();
	source.setServerName(HOST);
	source.setDatabaseName(getRepositoryName()+"?searchpath=cdoserver"); //$NON-NLS-1$
	source.setUser(USER);
	source.setPassword(PASS);
	source.setPortNumber(PORT);
	return source;
}
 
开发者ID:opencanarias,项目名称:model-repository-benchmark,代码行数:10,代码来源:JVMPostgresCDOModelRepository.java

示例15: getConnection

import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
/**
 * Returns a manual commit, read uncommitted connection.
 */
public static Connection getConnection(final String jdbcURL)
{
  // for the time being, only postgresql
  if (!jdbcURL.startsWith("jdbc:postgresql"))
  {
    return null;
  }
  // try
  // {
  // Class.forName("org.postgresql.Driver");
  // }
  // catch (final ClassNotFoundException e)
  // {
  // e.printStackTrace();
  // return null;
  // }
  try
  {
    // jdbc:postgresql://localhost/jive?user=jive&password=
    final PGSimpleDataSource ds = new PGSimpleDataSource();
    ds.setUser("jive");
    ds.setDatabaseName("jive");
    ds.setServerName("localhost");
    ds.setPassword("");
    final Connection conn = ds.getConnection();
    conn.setAutoCommit(false);
    conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    return conn;
  }
  catch (final SQLException e)
  {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:UBPL,项目名称:jive,代码行数:39,代码来源:JDBCTools.java


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