use of oracle.jdbc.pool.OracleDataSource in project adempiere by adempiere.
the class JdbcTest method main.
/**
* Main Test Start
* @param args
*/
public static void main(String[] args) {
try {
/* Load the JDBC driver */
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
s_ds = new OracleDataSource();
s_ds.setDriverType(DRIVER);
s_ds.setServerName("dev");
s_ds.setNetworkProtocol("tcp");
s_ds.setDatabaseName("dev1");
s_ds.setPortNumber(1521);
s_ds.setUser("adempiere");
s_ds.setPassword("adempiere");
/*
s_cc = new OracleConnectionCacheImpl();
s_cc.setDriverType(DRIVER);
s_cc.setServerName("dev");
s_cc.setNetworkProtocol("tcp");
s_cc.setDatabaseName("dev1");
s_cc.setPortNumber(1521);
s_cc.setUser("adempiere");
s_cc.setPassword("adempiere");
s_cc.setMaxLimit(NUM_OF_THREADS/4);
s_cc.setCacheScheme(OracleConnectionCacheImpl.FIXED_WAIT_SCHEME);
// s_cc.setCacheScheme(OracleConnectionCacheImpl.DYNAMIC_SCHEME);
*/
s_fetchSize = 10;
s_cType = C_MULTIPLE;
statementTiming();
statementTiming();
statementTiming();
s_cType = C_DATASOURCE;
statementTiming();
statementTiming();
statementTiming();
s_cType = C_CACHE;
statementTiming();
statementTiming();
statementTiming();
s_fetchSize = 20;
s_cType = C_MULTIPLE;
statementTiming();
statementTiming();
statementTiming();
s_cType = C_DATASOURCE;
statementTiming();
statementTiming();
statementTiming();
s_cType = C_CACHE;
statementTiming();
statementTiming();
statementTiming();
//
// standard value
s_fetchSize = 10;
/**
s_rType = R_JDBC_ROWSET;
rowSetTiming();
rowSetTiming();
rowSetTiming();
s_rType = R_CACHED_ROWSET;
rowSetTiming();
rowSetTiming();
rowSetTiming();
**/
//
s_cType = C_SHARED;
s_do_yield = false;
runTest();
runTest();
s_do_yield = true;
runTest();
runTest();
//
s_cType = C_MULTIPLE;
s_do_yield = false;
runTest();
runTest();
s_do_yield = true;
runTest();
runTest();
//
s_cType = C_PRECREATED;
s_do_yield = false;
runTest();
runTest();
s_do_yield = true;
runTest();
runTest();
//
s_cType = C_DATASOURCE;
s_do_yield = false;
runTest();
runTest();
s_do_yield = true;
runTest();
runTest();
//
s_cType = C_CACHE;
s_do_yield = false;
runTest();
runTest();
s_do_yield = true;
runTest();
runTest();
//
} catch (Exception e) {
e.printStackTrace();
}
}
use of oracle.jdbc.pool.OracleDataSource in project spring-boot by spring-projects.
the class DataSourceBuilderTests method buildWhenOracleTypeSpecifiedReturnsExpectedDataSource.
@Test
void buildWhenOracleTypeSpecifiedReturnsExpectedDataSource() throws SQLException {
this.dataSource = DataSourceBuilder.create().url("jdbc:oracle:thin:@localhost:1521:xe").type(OracleDataSource.class).username("test").build();
assertThat(this.dataSource).isInstanceOf(OracleDataSource.class);
OracleDataSource oracleDataSource = (OracleDataSource) this.dataSource;
assertThat(oracleDataSource.getURL()).isEqualTo("jdbc:oracle:thin:@localhost:1521:xe");
assertThat(oracleDataSource.getUser()).isEqualTo("test");
}
use of oracle.jdbc.pool.OracleDataSource in project spring-boot by spring-projects.
the class DataSourceBuilderTests method buildWhenOracleTypeSpecifiedWithDriverClassReturnsExpectedDataSource.
// gh-26631
@Test
void buildWhenOracleTypeSpecifiedWithDriverClassReturnsExpectedDataSource() throws SQLException {
this.dataSource = DataSourceBuilder.create().url("jdbc:oracle:thin:@localhost:1521:xe").type(OracleDataSource.class).driverClassName("oracle.jdbc.pool.OracleDataSource").username("test").build();
assertThat(this.dataSource).isInstanceOf(OracleDataSource.class);
OracleDataSource oracleDataSource = (OracleDataSource) this.dataSource;
assertThat(oracleDataSource.getURL()).isEqualTo("jdbc:oracle:thin:@localhost:1521:xe");
assertThat(oracleDataSource.getUser()).isEqualTo("test");
}
use of oracle.jdbc.pool.OracleDataSource in project ats-framework by Axway.
the class DbConnOracle method getDataSource.
@Override
public DataSource getDataSource() {
try {
dataSource = new OracleDataSource();
dataSource.setServerName(this.host);
dataSource.setUser(this.user);
dataSource.setPassword(this.password);
if (db != null && !"".equals(db)) {
// case when SID or serviceName is not used
dataSource.setDatabaseName(this.db);
}
dataSource.setURL(this.url);
// enable connection caching - we'll have pooled connections this way
dataSource.setConnectionCachingEnabled(true);
if (useEncryption && this.customProperties != null) {
if (this.customProperties.containsKey(OracleKeys.KEY_STORE_FULL_PATH) && this.customProperties.containsKey(OracleKeys.KEY_STORE_TYPE) && this.customProperties.containsKey(OracleKeys.KEY_STORE_PASSWORD)) {
Properties sslConnectionProperties = new Properties();
sslConnectionProperties.setProperty(OracleKeys.KEY_STORE_FULL_PATH, this.customProperties.get(OracleKeys.KEY_STORE_FULL_PATH).toString());
sslConnectionProperties.setProperty(OracleKeys.KEY_STORE_TYPE, this.customProperties.get(OracleKeys.KEY_STORE_TYPE).toString());
sslConnectionProperties.setProperty(OracleKeys.KEY_STORE_PASSWORD, this.customProperties.get(OracleKeys.KEY_STORE_PASSWORD).toString());
// this property is set just in case, later we should remove it
sslConnectionProperties.setProperty("javax.net.ssl.trustAnchors", this.customProperties.get(OracleKeys.KEY_STORE_PASSWORD).toString());
dataSource.setConnectionProperties(sslConnectionProperties);
} else {
log.info("Not all custom properties starting as DbConnection.KEY_STORE_XXX are set. We will try to prepare a default secure connection to Oracle DB");
try {
Certificate[] certs = SslUtils.getCertificatesFromSocket(host, String.valueOf(port));
dataSource.setConnectionProperties(SslUtils.createKeyStore(certs[0], this.host, this.db, "", "", ""));
} catch (Exception e) {
throw new DbException("Secure connection to Oracle DB could not be prepared due to failure in creating default certificate.", e);
}
}
}
return dataSource;
} catch (SQLException e) {
throw new DbException("Unable to create database source", e);
}
}
Aggregations