本文整理汇总了Java中org.postgresql.ds.PGSimpleDataSource.setPortNumber方法的典型用法代码示例。如果您正苦于以下问题:Java PGSimpleDataSource.setPortNumber方法的具体用法?Java PGSimpleDataSource.setPortNumber怎么用?Java PGSimpleDataSource.setPortNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.ds.PGSimpleDataSource
的用法示例。
在下文中一共展示了PGSimpleDataSource.setPortNumber方法的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;
}
示例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;
}
}
示例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;
}
};
}
示例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;
}
示例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;
}
}
示例6: 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);
}
}
示例7: 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;
}
示例8: 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);
}
示例9: 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);
}
示例10: 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
示例11: 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;
}
示例12: createDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
/**
* Create a new database, and return it as a DataSource.
* No two invocations will return the same database.
*/
public DataSource createDataSource() throws SQLException
{
final DbInfo db = dbPreparer.getNextDb();
final PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setPortNumber(db.port);
ds.setDatabaseName(db.dbName);
ds.setUser(db.user);
return ds;
}
示例13: dataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Bean(name = "sampledb")
public DataSource dataSource() {
PGSimpleDataSource d = new PGSimpleDataSource();
d.setServerName(host);
d.setDatabaseName(databaseName);
d.setPortNumber(portNumber);
d.setUser(user);
d.setPassword(password);
return d;
}
示例14: getAdminDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override public DataSource getAdminDataSource()
{
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName(this.getHostName());
ds.setPortNumber(this.getPort());
ds.setUser(this.getAdminUsername());
ds.setPassword(this.getAdminPassword());
ds.setDatabaseName("postgres");
return ds;
}
示例15: getAppDataSource
import org.postgresql.ds.PGSimpleDataSource; //导入方法依赖的package包/类
@Override public DataSource getAppDataSource()
{
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName(this.getHostName());
ds.setPortNumber(this.getPort());
ds.setUser(this.getAdminUsername());
ds.setPassword(this.getAdminPassword());
ds.setDatabaseName(this.getDatabaseName().toLowerCase());
return ds;
}