private static void setCredentials( BasicDataSource ds, DatabaseMeta databaseMeta, String partitionId ) throws KettleDatabaseException { String userName = databaseMeta.environmentSubstitute( databaseMeta.getUsername() ); String password = databaseMeta.environmentSubstitute( databaseMeta.getPassword() ); password = Encr.decryptPasswordOptionallyEncrypted( password ); ds.addConnectionProperty( "user", Const.NVL( userName, "" ) ); ds.addConnectionProperty( "password", Const.NVL( password, "" ) ); }
static void addConnectionProperties(BasicDataSource dataSource) { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); // config.enableSpatiaLite(true); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String) e.getKey(), (String) e.getValue()); } } }
/** * Configures an Apache Commons data source with the specified properties. */ private void configureDataSource(@Nonnull final org.apache.commons.dbcp.BasicDataSource dataSource, @Nonnull final com.thinkbiganalytics.db.DataSourceProperties props) { dataSource.setDriverClassLoader(props.getDriverClassLoader()); dataSource.setValidationQuery(props.getValidationQuery()); dataSource.setTestOnBorrow(true); if (props.getProperties() != null) { for (final Map.Entry<Object, Object> entry : props.getProperties().entrySet()) { dataSource.addConnectionProperty((String) entry.getKey(), (String) entry.getValue()); } } }
static void addConnectionProperties(BasicDataSource dataSource, Map configuration) throws IOException { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); Object synchronous = READ_ONLY.lookUp(configuration); if (Boolean.TRUE.equals(synchronous)) { config.setPragma(SQLiteConfig.Pragma.SYNCHRONOUS, "OFF"); config.setReadOnly(true); } // config.setPragma(SQLiteConfig.Pragma.MMAP_SIZE, "268435456"); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String) e.getKey(), (String) e.getValue()); } }
@Override public void addConnectionProperty(String name, String value) { delegate.addConnectionProperty(name, value); }
@Override public void setRewriteBatchedStatements(final boolean rewriteBatchedStatements) { super.addConnectionProperty(REWRITE_BATCHED_STATEMENTS, String.valueOf(rewriteBatchedStatements)); }
protected void setConnectionProperties(Map<String, String> props) { for (String name : props.keySet()) { dataSource.addConnectionProperty(name, props.get(name)); } }
private void addConnectionProperties(BasicDataSource basicDataSource, Properties dataSourceProperties) { for (Object key : dataSourceProperties.keySet()) { basicDataSource.addConnectionProperty((String) key, dataSourceProperties.getProperty((String) key)); } } }
protected void setConnectionProperties(Map<String, String> props) { for (String name : props.keySet()) { dataSource.addConnectionProperty(name, props.get(name)); } }
protected void addParameters(BasicDataSource basicDataSource, Map<String, Object> properties) { if (!isEmpty(properties)) { for (Map.Entry<String, Object> entry : properties.entrySet()) { basicDataSource.addConnectionProperty(entry.getKey(), (String) entry.getValue()); } } }
private BasicDataSource newDbcpConfiguration(Map map) { BasicDataSource basicDataSource = new BasicDataSource(); Iterator props = map.keySet().iterator(); while (props.hasNext()) { String propertyName = (String) props.next(); if (propertyName.startsWith(ADD_DRIVER_PROPS_PREFIX)) { String value = (String) map.get(propertyName); basicDataSource.addConnectionProperty(propertyName.substring(ADD_DRIVER_PROPS_PREFIX_LENGTH), value); } else if (PROBE.hasWritableProperty(basicDataSource, propertyName)) { String value = (String) map.get(propertyName); Object convertedValue = convertValue(basicDataSource, propertyName, value); PROBE.setObject(basicDataSource, propertyName, convertedValue); } } return basicDataSource; }
private BasicDataSource newDbcpConfiguration(Map map) { BasicDataSource basicDataSource = new BasicDataSource(); Iterator props = map.keySet().iterator(); while (props.hasNext()) { String propertyName = (String) props.next(); if (propertyName.startsWith(ADD_DRIVER_PROPS_PREFIX)) { String value = (String) map.get(propertyName); basicDataSource.addConnectionProperty(propertyName.substring(ADD_DRIVER_PROPS_PREFIX_LENGTH), value); } else if (PROBE.hasWritableProperty(basicDataSource, propertyName)) { String value = (String) map.get(propertyName); Object convertedValue = convertValue(basicDataSource, propertyName, value); PROBE.setObject(basicDataSource, propertyName, convertedValue); } } return basicDataSource; }
Properties props = new Properties(); ... load from properties file or XML BasicDataSource ds = new BasicDataSource(); for(Entry e : props.entrySet()) { ds.addConnectionProperty((String)e.getKey(), (String)e.getValue()); }
static void addConnectionProperties(BasicDataSource dataSource) { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); // config.enableSpatiaLite(true); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String) e.getKey(), (String) e.getValue()); } } }
static void addConnectionProperties(BasicDataSource dataSource) { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); config.enableSpatiaLite(true); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String)e.getKey(), (String)e.getValue()); } }
@Override protected void initializeBasicDataSource( BasicDataSource dataSource, Task task, Application application) { String openModes = getConfigValue( "OpenModes" ); if ( ! StringUtils.isBlank( openModes ) ) { SQLiteConfig config = new SQLiteConfig(); String[] modes = openModes.split( "," ); for ( String mode : modes ) config.setOpenMode(SQLiteOpenMode.valueOf( mode.trim().toUpperCase() ) ); Properties props = config.toProperties(); task.log().info( "Sqlite: setting open modes = %s", props ); for ( Object prop : props.keySet() ) dataSource.addConnectionProperty( prop.toString(), props.getProperty( prop.toString() ) ); } } }
/** * Configures an Apache Commons data source with the specified properties. */ private void configureDataSource(@Nonnull final org.apache.commons.dbcp.BasicDataSource dataSource, @Nonnull final com.thinkbiganalytics.db.DataSourceProperties props) { dataSource.setDriverClassLoader(props.getDriverClassLoader()); dataSource.setValidationQuery(props.getValidationQuery()); dataSource.setTestOnBorrow(true); if (props.getProperties() != null) { for (final Map.Entry<Object, Object> entry : props.getProperties().entrySet()) { dataSource.addConnectionProperty((String) entry.getKey(), (String) entry.getValue()); } } }
static void addConnectionProperties(BasicDataSource dataSource, Map configuration) throws IOException { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); Object synchronous = READ_ONLY.lookUp(configuration); if (Boolean.TRUE.equals(synchronous)) { config.setPragma(SQLiteConfig.Pragma.SYNCHRONOUS, "OFF"); config.setReadOnly(true); } // config.setPragma(SQLiteConfig.Pragma.MMAP_SIZE, "268435456"); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String) e.getKey(), (String) e.getValue()); } }
private static DataSource createFromJdbcUrl(Class<? extends Driver> driverClass, String url, Credential credential, int numThreads, ImmutableList<String> initSqls, Properties extraConnectionProperties) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverClass.getName()); dataSource.setUrl(url); dataSource.setUsername(credential.getUsername()); dataSource.setPassword(credential.getPassword()); // connection pool settings dataSource.setInitialSize(numThreads); dataSource.setMaxActive(numThreads); // keep the connections open if possible; only close them via the removeAbandonedTimeout feature dataSource.setMaxIdle(numThreads); dataSource.setMinIdle(0); dataSource.setRemoveAbandonedTimeout(300); dataSource.setConnectionInitSqls(initSqls.castToList()); if (extraConnectionProperties != null) { for (String key : extraConnectionProperties.stringPropertyNames()) { dataSource.addConnectionProperty(key, extraConnectionProperties.getProperty(key)); } } return dataSource; } }
private static DataSource createFromJdbcUrl(Class<? extends Driver> driverClass, String url, Credential credential, int numThreads, ImmutableList<String> initSqls, Properties extraConnectionProperties) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driverClass.getName()); dataSource.setUrl(url); dataSource.setUsername(credential.getUsername()); dataSource.setPassword(credential.getPassword()); // connection pool settings dataSource.setInitialSize(numThreads); dataSource.setMaxActive(numThreads); // keep the connections open if possible; only close them via the removeAbandonedTimeout feature dataSource.setMaxIdle(numThreads); dataSource.setMinIdle(0); dataSource.setRemoveAbandonedTimeout(300); dataSource.setConnectionInitSqls(initSqls.castToList()); if (extraConnectionProperties != null) { for (String key : extraConnectionProperties.stringPropertyNames()) { dataSource.addConnectionProperty(key, extraConnectionProperties.getProperty(key)); } } return dataSource; } }