I want to use JDBC Connetion in my webapp, which is configured in WebSphere. (Like here: How to use JDBC in JavaEE? )
I used this DataSource before through JPA, but our client wants to have their own SQL ... don't ask.
I found many examples and tutorials (e.g. http://www.wickcentral.com/java/dl/ds_resreferencesetts_Websphere.pdf , Websphere search in JSDI fails ), but nothing needs to work.
WebSphere DataSource has a JNDI name of "jdbc / myDS"
I added the ref resource to my web.xml:
<resource-ref> <res-ref-name>jdbc/myDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>
And I tried to get a DataSource in my Dao:
ds = (DataSource) new InitialContext() .lookup("java:comp/env/jdbc/myDS");
But I get
com.ibm.wsspi.injectionengine.InjectionException: CWNEN0044E: A resource reference binding could not be found for the following resource references [jdbc/myDS], defined for the MyAPP component.
I've tried a lot. Has anyone seen a mistake?
source share