HP Integrity NonStop J-Series User Manual
Page 114

jdbc-0.proxool.alias=property
jdbc-0.proxool.driver-url=jdbc:t4sqlmx://<machine name>:<port number>
jdbc-0.proxool.driver-class=com.tandem.t4jdbc.SQLMXDriver
jdbc-0.user=<user id>
jdbc-0.password=<password>
jdbc-0.proxool.maximum-connection-count=15
jdbc-0.proxool.minimum-connection-count=5
For a list of Proxool properties, see
Using JNDI datasource with C3P0 connection pooling
Steps to use JNDI datasource with C3P0 connection pooling are as follows:
1.
Define a bean for datasource in the applicationContext.xml file. For example:
For T2 driver:
<bean id="T2bean" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.tandem.sqlmx.SQLMXDriver" />
<property name="jdbcUrl" value="jdbc:sqlmx://" />
<property name="initialPoolSize" value="2" />
<property name="maxPoolSize" value="5" />
<property name="minPoolSize" value="2" />
<property name="maxStatements" value="50" />
</bean>
For T4 driver:
<bean id="T4bean" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.tandem.t4jdbc.SQLMXDriver" />
<property name="jdbcUrl" value="jdbc:t4sqlmx://<HP NonStop System IP Address>:<Port No.>" />
<property name="user" value="<HP NonStop Username>" />
<property name="password" value="<HP NonStop Password>" />
<property name="initialPoolSize" value="2" />
<property name="maxPoolSize" value="5" />
<property name="minPoolSize" value="2" />
<property name="maxStatements" value="50" />
</bean>
2.
Register this bean as a JNDI datasource by writing a few lines of code as follows. The context
referred here is a Spring application context.
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:///home/dataSources");
Object datasource=context.getBean("T2bean"); // for T4 you can use T4Bean
try {
Context ctx = new InitialContext(env);
ctx.rebind("jndi",datasource );
}
catch (Exception e) {
}
3.
Use this JNDI datasource in a Spring Hibernate application. The applicationContext.xml
can be configured as follows:
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</prop>
<prop key="java.naming.provider.url">file:///home/dataSources</prop>
</props>
</property>
</bean>
<bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>jndi</value>
</property>
</bean>
Now this jndiDataSource can be set on hibernate session factory as follows:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="jndiDataSource"/></property>
114
Hibernate Framework