db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandeep Bghavatula" <sbhagavat...@comframe.com>
Subject RE: Torque not closing database connections
Date Tue, 13 Dec 2005 16:12:05 GMT
Thanks for all the replies. I got a chance to spend some time again on this issue and I was
able to resolve it. We were using Jetspeed 1.4, with Torque 3.0 and tomcat 4.1.27. Jetspeed
1.4 comes with commons-dbcp-1.0-dev-20020806.jar and commons-pool-1.0.jar as default. There
is a bug in this version of dbcp that is responsible for all the open connections. It never
releases the stale connections. Every time a connection times out, it would go and get a new
connection. I updated commons dbcp and commons pool and everything is fine now. 
 
Thanks again 
 
Sandeep 

________________________________

From: Guy Galil [mailto:Guy_Galil@guardium.com]
Sent: Mon 10/3/2005 8:49 AM
To: Apache Torque Users List
Subject: RE: Torque not closing database connections



I am using Torque 3.0 in our product for over two years with no such
problems.
following is a snippet from our Torque.properties:
torque.database.default.adapter=mysql
torque.dsfactory.default.factory=org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
#torque.dsfactory.default.factory=org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.default.pool.defaultMaxActive=30
torque.dsfactory.default.pool.testOnBorrow=true
torque.dsfactory.default.pool.validationQuery=SELECT 1
torque.dsfactory.default.connection.driver=org.gjt.mm.mysql.Driver
torque.dsfactory.default.connection.url =jdbc:mysql://127.0.0.1/tatabase
torque.dsfactory.default.connection.user = user
torque.dsfactory.default.connection.password = password
#torque.dsfactory.default.pool.defaultMaxConnections=30
#torque.dsfactory.default.pool.maxExpiryTime=3600
#torque.dsfactory.default.pool.connectionWaitTimeout=10

torque.idbroker.cleverquantity=true
torque.manager.useCache = true

Good luck Guy
 On Sat, 2005-10-01 at 15:02 +0200, Thomas Fischer wrote:
>
>
>
> No, Torque.shutdown() should be the inverse of Torque.init() and should be
> called only once if the application stops. Among other things, it tries to
> close any database pools generated by Torque.init() if possible.
> I typically put it in the destroy method of the main servlet of my
> application.
>
>    Thomas
>
> Jim Caserta <smoothie_jc@yahoo.com> schrieb am 01.10.2005 14:51:06:
>
> > Thomas,
> >
> > Is using the Shutdown also recommended as follows?
> >
> > try
> >         {
> >             db = Torque.getConnection(DATABASE_NAME);
> >                  }
> >         finally
> >         {
> >             Torque.closeConnection(db);
> >             Torque.shutdown() <<============
> >         }
> >
> > Jim
> >
> > --- Thomas Fischer <fischer@seitenbau.net> wrote:
> >
> > >
> > >
> > >
> > >
> > > I do not know much about Torque 3.0. All I can say
> > > about it is that I did
> > > not hear any problems about this in Torque 3.1 and
> > > later.
> > >
> > > In principal, the reasons can be the following:
> > > 1) the database pool is faulty (threading issues or
> > > similar). You can try
> > > to check this by updating to the newest dbcp version
> > > 1.2.1 and configure
> > > Torque to use it.
> > > 2) There is an error in Torque code somewhere.
> > > Personally, this seems quite
> > > improbable to me.
> > > 3) You do not close the database connections
> > > correctly. For example, the
> > > following is not enough
> > >
> > > Connection connection = Torque.getConnection()
> > > // do something with connection
> > > connection.close();
> > >
> > > because if an exception is happening before you call
> > > close, the connection
> > > will not be closed.
> > >
> > > You need to do something like the following to be on
> > > the safe side (I left
> > > out various catch blocks in order to show the
> > > principle)
> > >
> > > Connection connection = null;
> > > try
> > > {
> > >   connection = Torque.getConnection();
> > >   // do something with connection
> > > }
> > > finally
> > > {
> > >   if (connection != null)
> > >   {
> > >     connection.close();
> > >     connection = null;
> > >   }
> > > }
> > >
> > > If nothing helps, you need to write a log file when
> > > you open a connection
> > > and when you close the connection and find out where
> > > this happens. This is
> > > best done by subclassing the pool you use.
> > >
> > >      Thomas
> > >
> > >
> > >
> > > "Sandeep Bghavatula" <sbhagavatula@comframe.com>
> > > schrieb am 30.09.2005
> > > 22:18:42:
> > >
> > > > We use torque3.0 with turbine in our web
> > > application. The database
> > > > is mysql. Torque does'nt seem to be closing the
> > > database
> > > > connections. We end up with 50-60 connections in a
> > > couple of days
> > > > and have to restart the tomcat instance every 3
> > > days to keep mysql
> > > > from throwing up and saying thats it!! In my code,
> > > I do a
> > > > connection.close() wherever I have a
> > > Torque.getConnection(). There
> > > > is nothing in the database logs. Here is my
> > > torque.properties file.
> > > > Please help!!!
> > > >
> > > > #
> > >
> > -------------------------------------------------------------------
> > > > # $Id: Torque.properties,v 1.1 2005/08/25 17:51:16
> > > jriley Exp $
> > > > #
> > > > # This is the configuration file for Torque.
> > > > #
> > > > # Note that strings containing "," (comma)
> > > characters must backslash
> > > > # escape the comma (i.e. '\,')
> > > > #
> > > > #
> > >
> > -------------------------------------------------------------------
> > > >
> > > > # NOTE NO torque. prefix on properties - this is a
> > > kluge to make it
> > > > also include the TR.properties
> > > >
> > > > torque.applicationRoot=.
> > > >
> > > > #
> > >
> > -------------------------------------------------------------------
> > > > #
> > > > #  L O G G I N G
> > > > #
> > > > #
> > >
> > -------------------------------------------------------------------
> > > > # We use Log4J for all Torque logging and we embed
> > > the log4j
> > > > # properties within our application configuration.
> > > > #
> > >
> > -------------------------------------------------------------------
> > > >
> > > > # THIS SEEMS TO BE IGNORED - HENCE IT IS
> > > DUPLICATED IN log4j.properties
> > > >
> > > >
> > >
> > log4j.appender.org.apache.file=${applicationRoot}/logs/log
> > > >
> > >
> > log4j.appender.org.apache.layout=org.apache.log4j.PatternLayout
> > > >
> > > >
> > >
> > log4j.appender.org.apache.layout.conversionPattern=%d
> > > [%t] %-5p %c - %m%n
> > > > log4j.appender.org.apache.append=false
> > > >
> > > > log4j.category.org.apache.torque=INFO,
> > > org.apache.torque
> > > >
> > >
> > log4j.appender.org.apache.torque=org.apache.log4j.FileAppender
> > > >
> > >
> >
> log4j.appender.org.apache.torque.file=${torque.applicationRoot}/logs/log.txt
>
> > >
> > > >
> > >
> > log4j.appender.org.apache.torque.layout=org.apache.log4j.PatternLayout
> > > >
> > >
> > log4j.appender.org.apache.torque.layout.conversionPattern=%d
> > > [%t] %
> > > > -5p %c - %m%n
> > > > log4j.appender.org.apache.torque.append=false
> > > > #
> > >
> > -------------------------------------------------------------------
> > > > #
> > > > #  T O R Q U E  P R O P E R T I E S
> > > > #
> > > > #
> > >
> > -------------------------------------------------------------------
> > > > # These are your database settings. Look in the
> > > > # org.apache.pool.* packages for more information.
> > > > #
> > > > # The parameters to connect to the default
> > > database.  You MUST
> > > > # configure these properly.
> > > > #
> > >
> > -------------------------------------------------------------------
> > > >
> > > >
> > > > torque.database.default=default
> > > > ###torque.database.default.adapter=hypersonic
> > > > torque.database.default.adapter = mysql
> > > > ### torque.database.default.adapter=oracle
> > > > ### torque.database.default.adapter=mssql
> > > >
> > > > ##
> > > > ## Using torque's old pool
> > > > ##
> > > > #torque.dsfactory.default.connection.driver =
> > > org.hsqldb.jdbcDriver
> > > > #torque.dsfactory.default.connection.url =
> > > jdbc:hsqldb:${webappRoot}
> > > > /WEB-INF/db/jetspeed
> > > > #torque.dsfactory.default.connection.user = sa
> > > > #torque.dsfactory.default.connection.password =
> > > >
> > > >
> > >
> > torque.dsfactory.default.factory=org.apache.torque.dsfactory.
> > > > TorqueDataSourceFactory
> > > > # The number of database connections to cache per
> > > ConnectionPool
> > > > instance (specified per database)
> > > >
> > > torque.dsfactory.default.pool.defaultMaxConnections
> > > = 10
> > > > torque.dsfactory.default.pool.maxExpiryTime = 3600
> > > >
> > > torque.dsfactory.default.pool.connectionWaitTimeout
> > > = 10
> > > >
> > > > ### MySQL
> > > > #torque.dsfactory.default.connection.driver =
> > > org.gjt.mm.mysql.Driver
> > > > torque.dsfactory.default.connection.driver =
> > > com.mysql.jdbc.Driver
> > > > torque.dsfactory.default.connection.url =
> > > jdbc:mysql://localhost:3306/*****
> > > > torque.dsfactory.default.connection.user = *****
> > > > torque.dsfactory.default.connection.password =
> > > *****
> > > >
> > > >
> > > > # The interval (in milliseconds) between which the
> > > PoolBrokerService
> > === message truncated ===
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message