1

I've been spending some time today trying to specify a websphere 6.1 db2 jndi data source in my spring mvc 3.0 application config. I've followed a guide a got at http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html.

When I do this....

web.xml

<resource-ref>
    <res-ref-name>jdbc/reportingManagerDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref> 

<resource-ref>
    <res-ref-name>jdbc/reportingManagerCustDbDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>

spring files

<bean id="ePosDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/reportingManagerDataSource"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="cache" value="true" />
    <property name="proxyInterface"  value="javax.sql.DataSource" />
</bean>

<jee:jndi-lookup id="ePosDataSource"
    jndi-name="jdbc/reportingManagerDataSource"
    cache="true"
    resource-ref="true"
    lookup-on-startup="false"
    proxy-interface="javax.sql.DataSource"/>    

<bean id="custDbDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/reportingManagerCustDbDataSource"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="cache" value="true" />
    <property name="proxyInterface"  value="javax.sql.DataSource" />
</bean>    

<jee:jndi-lookup id="custDbDataSource"
    jndi-name="jdbc/reportingManagerCustDbDataSource"
    cache="true"
    resource-ref="true"
    lookup-on-startup="false"
    proxy-interface="javax.sql.DataSource"/>                            

I get the error ...

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: DSRA8101E: DataSource class cannot be used as one-phase: ClassCastException: com.ibm.db2.jcc.DB2XADataSource incompatible with javax.sql.ConnectionPoolDataSource

I have been frantically googling away to try and find a solution but have been unsuccessful. Can someone show me what is required to successfully set up my datasource please?

thanks

Richie
  • 4,989
  • 24
  • 90
  • 177
  • Ignore this question. After I restarted the server it all worked! – Richie May 01 '14 at 06:55
  • 2
    According to the [product manual](http://pic.dhe.ibm.com/infocenter/wxdinfo/v6r0/topic/com.ibm.websphere.messages.doc/com.ibm.IBMDataStoreAdapterNLS.html), the suggested action for this error is to set the data source property `'enable2Phase'` to `true` for `XADataSource` or `false` for `ConnectionPoolDataSource`. – mustaccio May 01 '14 at 17:43

0 Answers0