File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connection pool" Watch "Connection pool" New topic

Connection pool

Alf Gomez

Joined: Sep 28, 2004
Posts: 3
Hi all,

I have a Struts/Hibernate/MySQL application that doesn�t work well when working intensive against the DB.

The problem, is that to get some result, we execute SELECT�s in a loop, and after a while it crashes.

The error displayed in Firefox is:
javax.servlet.ServletException: Cannot open connection

But in the log, appears:
[2008-01-25 12:51:00,494] - SQL Error: 0, SQLState: 08S01
[2008-01-25 12:51:00,494] - Communications link failure due to underlying exception:

MESSAGE: Address already in use: connect

STACKTRACE: Address already in use: connect

I have read that the cause is that we exceed the number of socket connections, because we don�t use a pool.

I have the following configuration:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/ph"/>
<property name="username" value="ph"/>
<property name="password" value="Ckue412lo"/>

<!-- Database Property -->
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>
<prop key="hibernate.show_sql">false</prop>

<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>


How can I configure a pool of connections?
It is integrated in the MySQL database, or I have to include some libraries?

Any help would be appreciated.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
There are several options for connection pooling.

I cannot comment on these options as I have never used any of them. All my development is server-side using WebLogic Server.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Alf Gomez

Joined: Sep 28, 2004
Posts: 3
Thanks Roger
I agree. Here's the link:
subject: Connection pool
It's not a secret anymore!