OracleDataSource ods = new OracleDataSource(); // set cache properties java.util.Properties prop = new java.util.Properties(); prop.setProperty("MinLimit", "2"); prop.setProperty("MaxLimit", "10"); // set DataSource properties String url = "jdbc:oracle:oci8:@"; ods.setURL(url); ods.setUser("hr"); ods.setPassword("hr"); ods.setConnectionCachingEnabled(true); // be sure set to true ods.setConnectionCacheProperties (prop); ods.setConnectionCacheName("ImplicitCache01"); // this cache's name // We need to create a connection to create the cache Connection conn = ds.getConnection(user, pass); Statement stmt = conn1.createStatement(); ResultSet rset = stmt.executeQuery("select user from dual"); conn1.close(); ods.close();
public void setDatabaseName(String dbname) { dataSource.setDatabaseName(dbname); }
public void setServerName(String sn) { dataSource.setServerName(sn); }
public ScriptRunner(final String jdbcUrl, final String username, final String password) throws SQLException { OracleDataSource ds = new OracleDataSource(); ds.setURL(jdbcUrl); ds.setUser(username); ds.setPassword(password); this.dataSource = ds; }
public void setConnectionCacheName(String s) throws SQLException { // the following have to be set together in this exact order dataSource.setConnectionCachingEnabled(true); dataSource.setFastConnectionFailoverEnabled(true); dataSource.setConnectionCacheName(s); }
props.putAll(configurationProperties); try { OracleDataSource ods = new OracleDataSource(); ods.setDriverType(props.getProperty("_driverType")); props.remove("_driverType"); ods.setNetworkProtocol(props.getProperty("_networkProtocol")); props.remove("_networkProtocol"); ods.setPortNumber(Integer.parseInt(props.getProperty("_portNumber"))); props.remove("_portNumber"); ods.setServerName(props.getProperty("_serverName")); props.remove("_serverName"); ods.setDatabaseName(props.getProperty("_databaseName")); props.remove("_databaseName"); ods.setUser(props.getProperty("user")); props.remove("user"); ods.setPassword(props.getProperty("password")); props.remove("password"); ods.setConnectionProperties(props); ods.setConnectionCachingEnabled(true); ods.setConnectionCacheName(source);
private static void configureDS(EntityConfig dbconfig, OracleDataSource ds) throws Exception { ds.setUser(dbconfig.getParameter("user")); ds.setPassword(dbconfig.getParameter("password")); if (dbconfig.getParameter("url")==null) { ds.setDriverType("thin"); ds.setPortNumber(dbconfig.getIntParameter("port")); ds.setServerName(dbconfig.getParameter("host")); ds.setDatabaseName(dbconfig.getParameter("sid")); } else ds.setURL(dbconfig.getParameter("url")); ds.setImplicitCachingEnabled(dbconfig.getBooleanParameter("implicit-caching")); ds.setExplicitCachingEnabled(dbconfig.getBooleanParameter("explicit-caching")); ds.setConnectionCachingEnabled(false); ds.setConnectionProperties(dbconfig.getPropertiesParameter("connection-properties")); }
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); dataSource.setConnectionCachingEnabled(true); 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) {
String password = extractPasswordfromDbUrl(dbUrl); OracleDataSource dataSource = (OracleDataSource) context.getBean("dataSource"); dataSource.setURL(url); dataSource.setUser(user); dataSource.setPassword(password); taskExecutor.setConcurrencyLimit(parallelCount); String userName = ((OracleDataSource) context.getBean("dataSource")).getUser(); isLaunchedByDBA = userName.toLowerCase().matches(".+as +sysdba *"); if (!isLaunchedByDBA){
oracle.jdbc.pool.OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource(); ds.setDriverType("thin"); ds.setServerName("localhost"); ds.setPortNumber(1521); ds.setDatabaseName("XE"); // Oracle SID Connection con = ds.getConnection(user, password);
public void setPassword(String pwd) { this.password = pwd; dataSource.setPassword(pwd); }
public void setUserName(String user) { dataSource.setUser(user); }
public void setURL(String s) { dataSource.setURL(s); }
@Override public boolean destroyDataSource(DataSource dataSource) { if (dataSource instanceof OracleDataSource){ try { ((OracleDataSource) dataSource).close(); return true; } catch (Exception e) { log.warn("Error destroying oracle data source: " + dataSource, e); } } return false; }
public void setConnectionProperties(String s) throws SQLException { // Should look something like the below, with any number of spaces around the "$" or "=" - // "oracle.net.ssl_cipher_suites=(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA,SSL_DH_anon_WITH_RC4_128_MD5)$MaxLimit=10" // "oracle.net.ssl_cipher_suites=(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA,SSL_DH_anon_WITH_RC4_128_MD5) $ MaxLimit=10" if (s == null) { return; } Properties props = new Properties(); String []args = s.trim().split("[$]"); for (String arg : args) { String[] prop = arg.trim().split("[ =]+"); if (prop.length == 2) { props.setProperty(prop[0], prop[1]); } else { try { if (getLogWriter() != null){ getLogWriter().println("setConnectionProperties(" + s + ")"); getLogWriter().println("Found invalid Oracle ConnectionProperties(" + prop.toString() + ")"); } } catch (ResourceException e) { throw new SQLException(e.getMessage()); } } } // Setup Connection Properties dataSource.setConnectionProperties(props); }
oracle.jdbc.pool.OracleDataSource ds = new oracle.jdbc.pool.OracleDataSource(); ds.setDriverType("thin"); ds.setServerName("localhost"); ds.setPortNumber(1521); ds.setDatabaseName("XE"); // Oracle SID ds.setUser("Herong"); ds.setPassword("TopSecret");
public void setPassword(String pwd) { this.password = pwd; dataSource.setPassword(pwd); }
public void setUserName(String user) { dataSource.setUser(user); }
public void setURL(String s) { dataSource.setURL(s); }
@Override public boolean reset(Object resource) throws Exception { if (canMap(resource)) { ((OracleDataSource) resource).close(); return true; } return false; }