I have the following code in a simple spring boot app...
@Bean
public DataSource getDatasource(){
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName(driver);
ds.setUsername(username);
ds.setUrl(url);
ds.setPassword(password);
return ds;
}
This worked great but I wanted connection pooling so I changed to...
@Bean
public DataSource getDatasource(){
try{
OracleConnectionPoolDataSource ds = new OracleConnectionPoolDataSource();
ds.setDriverType("thin");
ds.setUser(username);
ds.setNetworkProtocol("tcp");
ds.setPassword(password);
ds.setDatabaseName(dbName);
ds.setServerName(serverName);
return ds;
} catch (SQLException throwables) {
logger.error(throwables);
System.exit(-1);
}
return null;
}
But from the documentation it looks like getConnection
just returns a native connection and I need to configure Spring to call getPooledConnection
instead.
Is there another bean I can create or some other way I can do this?