Wednesday, December 28, 2011

Using Glassfish built-in connection pool (rather than dbcp or c3p0)

From http://skytteren.blogspot.com/2009/06/using-mysql-connection-pool-in.html


Using MySQL connection pool in Glassfish V3
I tried with a simple data source in Spring, but it isn't meant for production environments. So I wanted to move from:

<bean id="simpleDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/database"/>
<property name="username" value="database"/>
<property name="password" value="s3cr3t"/>
</bean>

to:

<bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/databasePool" />
</bean>

This can be done from within Glassfish admin, by creating the connection pool with the specified jndi name.

No comments:

Post a Comment