Results 1 to 2 of 2

Thread: can't close connection while SQLException happen

  1. #1
    Join Date
    Jun 2006
    Posts
    5

    Default can't close connection while SQLException happen

    I'v schedule application that interactive on database periodically. as application get connection through dbcp and continue, the SQLException was catched due to some reason;program break this route and wait next schedule, but next schedule encounter same SQLException, my memory then hold by many many database process( in my postgresql database is postgres.exe) as if my connections can't close by dbcp.

    my question is how to configure to close those connections when SQLException happen,otherwise my memory will be occupy by those unreleased connection till my machine breakdown.

    here is my configuration in spring application context declaration.
    ------------------------------------------------------------------------------------------------------------
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    abstract="false" singleton="true" lazy-init="default" autowire="default"
    dependency-check="default">
    <property name="driverClassName">
    <value>org.postgresql.Driver</value>
    </property>
    <property name="url">
    <value>jdbcostgresql://127.0.0.1/irisApp</value>
    </property>
    <property name="username">
    <value>postgres</value>
    </property>
    <property name="password">
    <value>postgres</value>
    </property>
    <property name="validationQuery">
    <value>SELECT 1</value>
    </property>
    <property name="maxActive" value="80" />
    <property name="maxIdle" value="10" />
    <property name="maxWait" value="2000" />
    <property name="poolPreparedStatements" value="true" />
    <property name="removeAbandoned" value="true" />
    </bean>
    ------------------------------------------------------------------------------------------------------------------
    any help?

    Regards

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Not sure how dbcp works but the connection should be recycled. I'd suggest to try c3p0 which is actively maintained and has plenty of parameters to tweak. The manual provides answer to most of the question but if you still encounter problems you can use their forums.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •