My production Springframework code doesn’t normally need to get the datasource directly because I choose to inject the template. However, sometimes there is a need to get the datasource.
The datasource is usually defined as
<jee:jndi-lookup id="jxportalDs" jndi-name="jdbc/jxportal"/>
If you try to inject that with
@Resource(name = "jxportalDs") private DataSource dataSource;
You will get compile problems because the the code declares a type of DataSource, but there is not a type declared for Datasource. This can be fixed by adding a type to your jndi declaration
<jee:jndi-lookup id="jxportalDs" jndi-name="jdbc/jxportal" expected-type="javax.sql.DataSource"/>
sheltonn December 6th, 2011