File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection pool" Watch "Connection pool" New topic
Author

Connection pool

Alf Gomez
Greenhorn

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:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.BindException: Address already in use: connect

STACKTRACE:

java.net.SocketException: java.net.BindException: 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"/>
</bean>

<!-- Database Property -->
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<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>

</props>
</property>
</bean>



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.

http://java-source.net/open-source/connection-pools

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
Greenhorn

Joined: Sep 28, 2004
Posts: 3
Thanks Roger
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection pool