We use Spring's JdbcTemplate
which is configured through Spring config as illustrated below. Is there a way to do this without injecting the data source? I'd like to just create the JdbcTemplate
instance programatically and "initalize" the datasource using TheOracleDS
.
Our current config:
Java class
private JdbcTemplate jdbcTemplate;
@Resource(name = "myDataSource")
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
Spring config
<jee:jndi-lookup id="myDataSource" jndi-name="java:/TheOracleDS"/>
Oracle datasource config
<xa-datasource>
<jndi-name>TheOracleDS</jndi-name>
...
</xa-datasource>
Update: Reason I'm asking this is I'm not a total believer in dependency injection / having Spring manage beans..