Thought I’d post a snippet of applicationContext.xml for all the people out there trying a JNDI data source wired up in IBM’s WebSphere Application Server through Spring Framework and Hibernate. I couldn’t find this information as a whole anywhere out there so hopefully it helps someone.
Hit the jump for the xml.
<beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/DB2"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- IBM WAS SPECIFIC -->
<prop key="hibernate.connection.datasource">jdbc/DB2</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</prop>
<!-- /END IBM WAS SPECIFIC -->
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="autodetectTransactionManager" value="false" />
</bean>
</beans>
LinkedIn
#1 by henry on July 11, 2008 - 4:01 am
thank you so much. I learning from your setting now, it is interesting, because there are many kinds of setting, yours looks good.
#2 by Simon on December 18, 2008 - 6:08 am
How to get it and use it?
#3 by Bruce Willis on January 16, 2009 - 4:31 am
Nice post!
Have you seen though this article? (google for ’0609_alcott’)
http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html
Is not clear to me whether your recommended settings and the ones in the article are equivalent.
#4 by Matt Brotherson on January 16, 2009 - 4:03 pm
Bruce, I had not seen that bit from IBM. I pieced together this recommendation based on several articles and my personal experience at a client site. That article appears to be more thorough and if my settings don’t function in your application I would defer to the article as your specific implementation may need extended settings.
#5 by Kontext on December 25, 2010 - 6:05 am
thanks, it is very usefull
#6 by Mrad Mohamed on March 17, 2011 - 1:56 pm
Very good
#7 by Hebert Rdz on February 3, 2012 - 2:00 am
Muy bueno, muchas gracias!!
#8 by sinhp on March 24, 2012 - 5:25 am
Thanks so much. But i have some ploblem. I insert uicode string with websphere and orcale not success. Can you help me!!!!