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


Java PGSimpleDataSource类代码示例

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


PGSimpleDataSource类属于org.postgresql.ds包,在下文中一共展示了PGSimpleDataSource类的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: Pagerank

import org.postgresql.ds.PGSimpleDataSource; //导入依赖的package包/类
public Pagerank(String postgresql) throws ClassNotFoundException, SQLException, IOException{
	//inits
	Class.forName("org.postgresql.Driver");
	this.ds = new PGSimpleDataSource();
	ds.setUrl(postgresql);
	ds.setUser("postgres");
	ds.setPassword("postgres");
	this.conn = ds.getConnection();
	
	loadData();
	
	size = sizeHaltestellen();
	P = new double[size][size];
	System.out.println("size: " + size);
	
	// fill P
	for(int i = 0; i<size; i++){
		for(int j = 0; j<size; j++){
			P[i][j] = 0;
		}
	}
	fillP();
	// printP();
}
 
开发者ID:becherd,项目名称:verteilteWebInf,代码行数:25,代码来源:Pagerank.java

示例6: initialSetup

import org.postgresql.ds.PGSimpleDataSource; //导入依赖的package包/类
/**
 * Installs the runway core. This entails creating a new database and a user
 * for the runway to log in with.
 */
public void initialSetup(String rootUser, String rootPass, String rootDb)
{
  // Set up the root connection
  BaseDataSource pgRootDataSource = new PGSimpleDataSource();
  pgRootDataSource.setServerName(DatabaseProperties.getServerName());
  pgRootDataSource.setPortNumber(DatabaseProperties.getPort());
  pgRootDataSource.setDatabaseName(rootDb);
  pgRootDataSource.setUser(rootUser);
  pgRootDataSource.setPassword(rootPass);
  this.rootDataSource = (DataSource) pgRootDataSource;
  // this.dropNamespace(rootUser, rootPass);
  this.dropDb();
  this.dropUser();
  this.createDb(rootDb);
  this.createUser();
  if (this.hasNamespace())
  {
    this.createNamespace(rootUser, rootPass);
  }
}
 
开发者ID:terraframe,项目名称:Runway-SDK,代码行数:25,代码来源:PostgreSQL.java

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

示例8: doResultTest

import org.postgresql.ds.PGSimpleDataSource; //导入依赖的package包/类
private static void doResultTest( final PGSimpleDataSource ds) {
	try {
		final Connection conn= ds.getConnection();
		try {
			resultSetTest( ds.getConnection());
		} catch( final SQLException e) {
			e.printStackTrace();
		} finally {
			if( conn != null) {
                   conn.close();
               }
		}
	} catch( final SQLException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:freiheit-com,项目名称:sqlapi4j,代码行数:17,代码来源:SqlApiTest.java

示例9: doResultTestGC

import org.postgresql.ds.PGSimpleDataSource; //导入依赖的package包/类
private static void doResultTestGC( final PGSimpleDataSource ds) {
	try {
		final Connection conn= ds.getConnection();
		try {
			resultSetTestGroupCount( ds.getConnection());
		} catch( final SQLException e) {
			e.printStackTrace();
		} finally {
			if( conn != null) {
                   conn.close();
               }
		}
	} catch( final SQLException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:freiheit-com,项目名称:sqlapi4j,代码行数:17,代码来源:SqlApiTest.java

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

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

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

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

示例14: toDb

import org.postgresql.ds.PGSimpleDataSource; //导入依赖的package包/类
private ConnectionPool toDb(DataSource source) {
	if (source instanceof PGSimpleDataSource) {
		return toDb((PGSimpleDataSource) source);
	} else {
		throw new IllegalStateException();
	}
}
 
开发者ID:RyanHoldren,项目名称:TypeSafeSQL,代码行数:8,代码来源:FunctionalTest.java

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


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