问题
I am currently moving my Oracle Datasource pool creation from my Spring config to a jetty config, but I am getting the error below
[WARNING] Config error at
My Datasource config in Spring looks like
@Bean
public DataSource dataSource() throws IllegalStateException, SQLException {
PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
dataSource.setConnectionFactoryClassName(env.getRequiredProperty(DB_CONNECTION_FACTORY_CLASS_NAME));
dataSource.setURL(env.getRequiredProperty(DATABASE_URL));
dataSource.setUser(env.getRequiredProperty(DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(DATABASE_PASSWORD));
dataSource.setMinPoolSize(Integer.parseInt(env.getRequiredProperty(DATABASE_CONNECTION_MIN_POOL_SIZE)));
dataSource.setMaxPoolSize(Integer.parseInt(env.getRequiredProperty(DATABASE_CONNECTION_MAX_POOL_SIZE)));
dataSource.setInitialPoolSize(Integer.parseInt(env.getRequiredProperty(DATABASE_CONNECTION_INITIAL_POOL_SIZE)));
return dataSource;
}
In the jetty config, it looks like
<New id="pds_datasource_pool" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref refid="wac"/></Arg>
<Arg>jdbc/pdsds</Arg>
<Arg>
<New class="oracle.ucp.jdbc.PoolDataSource">
<Set name="uRL">jdbc:oracle:thin:xxx</Set>
<Set name="user">user</Set>
<Set name="password">user_dev_01</Set>
<Set name="minPoolSize">2</Set>
<Set name="maxPoolSize">10</Set>
<Set name="initialPoolSize">2</Set>
<Set name="connectionFactoryClassName">oracle.jdbc.replay.OracleDataSourceImpl</Set>
</New>
</Arg>
The logs only show the error mentioned above and I am not too sure what the problem is. I also included the 2 Oracle jars as dependencies but does not seem to work.
Ay help is appreciated.
Cheers
Kris
回答1:
Answering my own post here. Here are the settings to configure pooling in Jetty
<New id="pDatasourcePool" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref refid="wac"/></Arg>
<Arg>jdbc/projectds</Arg>
<Arg>
<Call class="oracle.ucp.jdbc.PoolDataSourceFactory" name="getPoolDataSource" >
<Set name="URL">jdbc:oracle:thin:xxx</Set>
<Set name="user">user</Set>
<Set name="password">ser_dev1</Set>
<Set name="minPoolSize">2</Set>
<Set name="maxPoolSize">10</Set>
<Set name="initialPoolSize">2</Set>
<Set name="connectionFactoryClassName">oracle.jdbc.replay.OracleDataSourceImpl</Set>
</Call>
</Arg>
来源:https://stackoverflow.com/questions/44625185/jetty-and-oracle-connection-pooling