@Override public DataSource tryCreateDataSource(DataSourceProps conf) throws NestedClassNotFoundException { if(!(conf.hasDataSourceClassName() || conf.hasDataSourceJndiName() || conf.hasDriverClassName())) { return null; pp.setDataSourceClassName(conf.getDataSourceClassName()); pp.setDataSourceJndiName(conf.getDataSourceJndiName()); if(conf.hasDataSourceJndiResourceRef()) { pp.setDataSourceJndiResourceRef(conf.getDataSourceJndiResourceRef()); pp.setDriverClassName(conf.getDriverClassName()); pp.setJdbcUrl(conf.getJdbcUrl()); pp.setUsername(conf.getUsername()); pp.setPassword(conf.getPassword()); if(conf.hasDefaultAutoCommit()) { pp.setDefaultAutoCommit(conf.getDefaultAutoCommit()); if(conf.hasDefaultReadOnly()) { pp.setDefaultReadonly(conf.getDefaultReadOnly()); if(conf.hasDefaultTransactionIsolation()) { pp.setDefaultTransactionIsolation(conf.getDefaultTransactionIsolation()); if(conf.hasDefaultCatalog()) { pp.setDefaultCatalog(conf.getDefaultCatalog()); if(conf.hasMaxActive()) { pp.setMaxActive(conf.getMaxActive());
@Override public DataSource tryCreateDataSource(DataSourceProps conf) throws NestedClassNotFoundException { String jndiName = conf.getDataSourceJndiName(); if(Strings.isEmpty(jndiName)) { return null; } boolean resourceRef = null == conf.getDataSourceJndiResourceRef() ? false : conf.getDataSourceJndiResourceRef(); try { return new JndiLocator(resourceRef).lookup(jndiName, DataSource.class); } catch (NamingException e) { throw new AppConfigException("Cannot loolup jndi DataSource '" + jndiName + "', " + e.getMessage(), e); } }
@Override public DataSource tryCreateDataSource(DataSourceProps conf) { ensureGetDriverClass(conf); UnPooledDataSource ds = new UnPooledDataSource(); ds.setDriverClassName(conf.getDriverClassName()); ds.setJdbcUrl(conf.getJdbcUrl()); ds.setUsername(conf.getUsername()); ds.setPassword(conf.getPassword()); ds.setDefaultAutoCommit(conf.getDefaultAutoCommit()); ds.setDriverProperties(conf.getExtProperties()); return ds; }
pp.setDriverClassName(props.getDriverClassName()); pp.setUrl(props.getJdbcUrl()); pp.setUsername(props.getUsername()); pp.setPassword(props.getPassword()); pp.setDefaultAutoCommit(props.getDefaultAutoCommit()); pp.setTestWhileIdle(true); pp.setTestOnBorrow(true); if(null != props.getDefaultTransactionIsolation()){ pp.setDefaultTransactionIsolation(props.getDefaultTransactionIsolation().getValue()); props.inject(pp); if(!props.getExtPropertiesMap().isEmpty()){ pp.setDbProperties(ExProperties.create(props.getExtPropertiesMap()));
protected DataSource newDataSource(MetaDataSource meta) throws SQLException { DataSourceProps props = new DataSourceProps.Builder(toMap(meta)).build(); log.debug("DataSource url '{}', username: {}", props.getJdbcUrl(), props.getUsername()); return dataSourceManager.createDataSource(props); }
this.defaultTransactionIsolation = getDefaultTransactionIsolation(properties); this.defaultReadOnly = Maps.getBoolean(properties, DEFAULT_READ_ONLY); this.defaultCatalog = properties.get(DEFAULT_CATALOG); this.extMap = extraceExtProperties(properties);
protected Class<?> tryGetDriverClass(DataSourceProps conf) throws NestedClassNotFoundException { if(!Strings.isEmpty(conf.getDriverClassName())){ return Classes.forName(conf.getDriverClassName()); } return null; }