File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection pool

 
Alf Gomez
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alf Gomez
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roger
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic