You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Nathan Modrzewski <nm...@eaglexm.com> on 2009/06/02 22:03:58 UTC

FW: Connection Closing Problem

I'm still having problems with this and have not been able to figure it
out. Anybody have any ideas?

Thanks,
  -- Nathan

-----Original Message-----
From: Nathan Modrzewski [mailto:nmodrzewski@eaglexm.com] 
Sent: Saturday, May 30, 2009 4:35 PM
To: user-java@ibatis.apache.org
Subject: Connection Closing Problem

I am having a problem with my Postgresql 8.3 connections not being
closed when the program is finished. Here are a few of the messages from
the Postgresql log file:

2009-05-30 16:18:59 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:02 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection


I'm sure its something I'm doing wrong. I am using Apache Dbcp for my
connection pooling. I'm using IBatis 2.3.4 and Apache DBCP 1.2.2. 

Below is a the xml settings I use for my IBatis and DBCP setup.


<sqlMapConfig>
    <settings
        useStatementNamespaces="true"
        cacheModelsEnabled="false"
        enhancementEnabled="false"
        lazyLoadingEnabled="false"
        maxRequests="1024"
        maxSessions="256"
        maxTransactions="64"
    />

    <transactionManager type="JDBC" commitRequired="true">
	    <property name="JDBC.DefaultAutoCommit" value="false" />
	    <property name="JDBC.SetAutoCommitAllowed" value="false" />
          <dataSource type="DBCP">
                <property name="driverClassName"
value="org.postgresql.Driver" />
                <property name="url"
value="jdbc:postgresql://db-05.eaglexm.com:5432/${database}" />
		    <property name="username" value="${username}" />
		    <property name="password" value="${password}" />
		    <property name="maxActive" value="32" />
		    <property name="maxIdle" value="5" />
		    <property name="maxWait" value="30000" />
		    <property name="validationQuery" value="select id
from system_settings" />
		    <property name="logAbandoned" value="false" />
		    <property name="timeBetweenEvictionRunsMillis"
value="60000" />
		    <property name="numTestsPerEvictionRun" value="5" />
		    <property name="minEvictableIdleTimeMillis"
value="600000" />
        </dataSource>
    </transactionManager>

    ... my "sqlMap" statements / includes ...
</sqlMapConfig>

Below is some java code that uses it:

Reader reader =
Resources.getResourceAsReader("ibatis_map/echodrive/server/SqlMapConfig.
xml");
try {
    map = SqlMapClientBuilder.buildSqlMapClient(reader,properties);
    map.startTransaction();
    try { 
        // Do some selects / updates / inserts
         
        map.commitTransaction();
    } finally {
        map.endTransaction();
    }
} finally {
    reader.close();
}

If anyone has any ideas, I would appreciate it.

Thanks,
  -- Nathan

RE: FW: Connection Closing Problem

Posted by Nathan Modrzewski <nm...@eaglexm.com>.
Thanks for the suggestion.  My connections are now being closed.

 

This list has been great. I want to thank everyone for helping me solve
this.

 

n  Nathan

 

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Tuesday, June 02, 2009 10:34 PM
To: user-java@ibatis.apache.org
Subject: Re: FW: Connection Closing Problem

 

Here's a simple unpooled datasource implementation....

 

http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-3/ibatis-3-core
/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.
java

 

Clinton

On Tue, Jun 2, 2009 at 10:32 PM, Clinton Begin <cl...@gmail.com>
wrote:

For standalone applications, you probably should not use a Connection
Pool.  In other words, you should either pass in your own connection, or
use a non-pooling datasource implementation.  I think you can achieve
this effect by setting the max idle connections on SimpleDataSource to
0, or you can just implement your own datasource and plug it into
iBATIS.  

 

The other way you could deal with it would be to cast the DataSource to
SimpleDataSource and call .forceCloseAll().  

 

Cheers,

Clinton

 

On Tue, Jun 2, 2009 at 9:59 PM, Nathan Modrzewski
<nm...@eaglexm.com> wrote:

I will look at doing that. Thanks for the info.

 

n  Nathan

 

From: Nicholoz Koka Kiknadze [mailto:kiknadze@gmail.com] 
Sent: Tuesday, June 02, 2009 3:02 PM


To: user-java@ibatis.apache.org
Subject: Re: FW: Connection Closing Problem

 

I think what happens to open (pooled) connection upon JVM exit depends
on JDBC driver.



IMO if you were using SimpleDataSource of iBatis, you'd have to call
forceCloseAll() to close all pooled connections at the end of execution
of your app (I think I have even used that years ago).  Not sure about
DBCP, but I bet  calling  basicDataSource.close() must help.

GL

On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski
<nm...@eaglexm.com> wrote:

Not yet...getting ready too.

 

If I'm using Apache Dbcp to handle connection pooling, do I have to
manually close the pooling objects?

 

 

 

 

 


Re: FW: Connection Closing Problem

Posted by Clinton Begin <cl...@gmail.com>.
Here's a simple unpooled datasource implementation....
http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java

Clinton

On Tue, Jun 2, 2009 at 10:32 PM, Clinton Begin <cl...@gmail.com>wrote:

> For standalone applications, you probably should not use a Connection Pool.
>  In other words, you should either pass in your own connection, or use a
> non-pooling datasource implementation.  I think you can achieve this effect
> by setting the max idle connections on SimpleDataSource to 0, or you can
> just implement your own datasource and plug it into iBATIS.
> The other way you could deal with it would be to cast the DataSource to
> SimpleDataSource and call .forceCloseAll().
>
> Cheers,
> Clinton
>
>
> On Tue, Jun 2, 2009 at 9:59 PM, Nathan Modrzewski <nmodrzewski@eaglexm.com
> > wrote:
>
>>  I will look at doing that. Thanks for the info.
>>
>>
>>
>> n  Nathan
>>
>>
>>
>> *From:* Nicholoz Koka Kiknadze [mailto:kiknadze@gmail.com]
>> *Sent:* Tuesday, June 02, 2009 3:02 PM
>> *To:* user-java@ibatis.apache.org
>> *Subject:* Re: FW: Connection Closing Problem
>>
>>
>>
>> I think what happens to open (pooled) connection upon JVM exit depends on
>> JDBC driver.
>>
>>
>> IMO if you were using SimpleDataSource of iBatis, you'd have to call
>> forceCloseAll() to close all pooled connections at the end of execution of
>> your app (I think I have even used that years ago).  Not sure about DBCP,
>> but I bet  calling  basicDataSource.close() must help.
>>
>> GL
>>
>>  On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski <
>> nmodrzewski@eaglexm.com> wrote:
>>
>> Not yet…getting ready too.
>>
>>
>>
>> If I’m using Apache Dbcp to handle connection pooling, do I have to
>> manually close the pooling objects?
>>
>>
>>
>>
>>
>>
>>
>
>

Re: FW: Connection Closing Problem

Posted by Clinton Begin <cl...@gmail.com>.
For standalone applications, you probably should not use a Connection Pool.
 In other words, you should either pass in your own connection, or use a
non-pooling datasource implementation.  I think you can achieve this effect
by setting the max idle connections on SimpleDataSource to 0, or you can
just implement your own datasource and plug it into iBATIS.
The other way you could deal with it would be to cast the DataSource to
SimpleDataSource and call .forceCloseAll().

Cheers,
Clinton

On Tue, Jun 2, 2009 at 9:59 PM, Nathan Modrzewski
<nm...@eaglexm.com>wrote:

>  I will look at doing that. Thanks for the info.
>
>
>
> n  Nathan
>
>
>
> *From:* Nicholoz Koka Kiknadze [mailto:kiknadze@gmail.com]
> *Sent:* Tuesday, June 02, 2009 3:02 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: FW: Connection Closing Problem
>
>
>
> I think what happens to open (pooled) connection upon JVM exit depends on
> JDBC driver.
>
>
> IMO if you were using SimpleDataSource of iBatis, you'd have to call
> forceCloseAll() to close all pooled connections at the end of execution of
> your app (I think I have even used that years ago).  Not sure about DBCP,
> but I bet  calling  basicDataSource.close() must help.
>
> GL
>
>  On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski <
> nmodrzewski@eaglexm.com> wrote:
>
> Not yet…getting ready too.
>
>
>
> If I’m using Apache Dbcp to handle connection pooling, do I have to
> manually close the pooling objects?
>
>
>
>
>
>
>

RE: FW: Connection Closing Problem

Posted by Nathan Modrzewski <nm...@eaglexm.com>.
I will look at doing that. Thanks for the info.

 

n  Nathan

 

From: Nicholoz Koka Kiknadze [mailto:kiknadze@gmail.com] 
Sent: Tuesday, June 02, 2009 3:02 PM
To: user-java@ibatis.apache.org
Subject: Re: FW: Connection Closing Problem

 

I think what happens to open (pooled) connection upon JVM exit depends
on JDBC driver.

IMO if you were using SimpleDataSource of iBatis, you'd have to call
forceCloseAll() to close all pooled connections at the end of execution
of your app (I think I have even used that years ago).  Not sure about
DBCP, but I bet  calling  basicDataSource.close() must help.

GL

On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski
<nm...@eaglexm.com> wrote:

Not yet...getting ready too.

 

If I'm using Apache Dbcp to handle connection pooling, do I have to
manually close the pooling objects?

 

 

 


RE: FW: Connection Closing Problem

Posted by Nathan Modrzewski <nm...@eaglexm.com>.
I have not set this...I will give it a try. Thanks for the suggestions. 

 

n  Nathan

 

From: Ashok Madhavan [mailto:ashok.madhavan@gmail.com] 
Sent: Tuesday, June 02, 2009 7:43 PM
To: user-java@ibatis.apache.org
Subject: Re: FW: Connection Closing Problem

 

Hi,

in apache dbcp did u set the following properties:

    <property name="removeAbandoned"><value>true</value></property>

    <property name="removeAbandonedTimeout"><value>1</value></property>

    <property name="logAbandoned"><value>true</value></property>

 

http://commons.apache.org/dbcp/configuration.html.
<http://commons.apache.org/dbcp/configuration.html> 

look for 'removeAbandoned'.

 

regards

ashok 

 

On Wed, Jun 3, 2009 at 2:32 AM, Nicholoz Koka Kiknadze
<ki...@gmail.com> wrote:

I think what happens to open (pooled) connection upon JVM exit depends
on JDBC driver.

IMO if you were using SimpleDataSource of iBatis, you'd have to call
forceCloseAll() to close all pooled connections at the end of execution
of your app (I think I have even used that years ago).  Not sure about
DBCP, but I bet  calling  basicDataSource.close() must help.

GL

 

On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski
<nm...@eaglexm.com> wrote:

Not yet...getting ready too.

 

If I'm using Apache Dbcp to handle connection pooling, do I have to
manually close the pooling objects?

 

 

 

 


Re: FW: Connection Closing Problem

Posted by Ashok Madhavan <as...@gmail.com>.
Hi,in apache dbcp did u set the following properties:
    <property name="removeAbandoned"><value>true</value></property>
    <property name="removeAbandonedTimeout"><value>1</value></property>
    <property name="logAbandoned"><value>true</value></property>

http://commons.apache.org/dbcp/configuration.html.<http://commons.apache.org/dbcp/configuration.html>
look for 'removeAbandoned'.

regards
ashok

On Wed, Jun 3, 2009 at 2:32 AM, Nicholoz Koka Kiknadze
<ki...@gmail.com>wrote:

> I think what happens to open (pooled) connection upon JVM exit depends on
> JDBC driver.
>
> IMO if you were using SimpleDataSource of iBatis, you'd have to call
> forceCloseAll() to close all pooled connections at the end of execution of
> your app (I think I have even used that years ago).  Not sure about DBCP,
> but I bet  calling  basicDataSource.close() must help.
>
> GL
>
>
> On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski <
> nmodrzewski@eaglexm.com> wrote:
>
>>  Not yet…getting ready too.
>>
>>
>>
>> If I’m using Apache Dbcp to handle connection pooling, do I have to
>> manually close the pooling objects?
>>
>>
>>
>>
>

Re: FW: Connection Closing Problem

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
I think what happens to open (pooled) connection upon JVM exit depends on
JDBC driver.

IMO if you were using SimpleDataSource of iBatis, you'd have to call
forceCloseAll() to close all pooled connections at the end of execution of
your app (I think I have even used that years ago).  Not sure about DBCP,
but I bet  calling  basicDataSource.close() must help.

GL

On Wed, Jun 3, 2009 at 12:18 AM, Nathan Modrzewski
<nm...@eaglexm.com>wrote:

>  Not yet…getting ready too.
>
>
>
> If I’m using Apache Dbcp to handle connection pooling, do I have to
> manually close the pooling objects?
>
>
>
>

RE: FW: Connection Closing Problem

Posted by Nathan Modrzewski <nm...@eaglexm.com>.
Not yet...getting ready too.

 

If I'm using Apache Dbcp to handle connection pooling, do I have to
manually close the pooling objects?

 

From: Sundar Sankar [mailto:fatboysuns@gmail.com] 
Sent: Tuesday, June 02, 2009 2:15 PM
To: user-java@ibatis.apache.org
Subject: Re: FW: Connection Closing Problem

 

Did u try stepping in through the Ibatis code to see what might actually
be happening when u make the call?

On Tue, Jun 2, 2009 at 1:03 PM, Nathan Modrzewski
<nm...@eaglexm.com> wrote:

I'm still having problems with this and have not been able to figure it
out. Anybody have any ideas?

Thanks,
 -- Nathan


-----Original Message-----
From: Nathan Modrzewski [mailto:nmodrzewski@eaglexm.com]
Sent: Saturday, May 30, 2009 4:35 PM
To: user-java@ibatis.apache.org

Subject: Connection Closing Problem

I am having a problem with my Postgresql 8.3 connections not being
closed when the program is finished. Here are a few of the messages from
the Postgresql log file:

2009-05-30 16:18:59 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection
2009-05-30 16:19:02 MDT [echodrive_machine @ echodrive]: LOG:
unexpected EOF on client connection


I'm sure its something I'm doing wrong. I am using Apache Dbcp for my
connection pooling. I'm using IBatis 2.3.4 and Apache DBCP 1.2.2.

Below is a the xml settings I use for my IBatis and DBCP setup.


<sqlMapConfig>
   <settings
       useStatementNamespaces="true"
       cacheModelsEnabled="false"
       enhancementEnabled="false"
       lazyLoadingEnabled="false"
       maxRequests="1024"
       maxSessions="256"
       maxTransactions="64"
   />

   <transactionManager type="JDBC" commitRequired="true">
           <property name="JDBC.DefaultAutoCommit" value="false" />
           <property name="JDBC.SetAutoCommitAllowed" value="false" />
         <dataSource type="DBCP">
               <property name="driverClassName"
value="org.postgresql.Driver" />
               <property name="url"
value="jdbc:postgresql://db-05.eaglexm.com:5432/${database}
<http://db-05.eaglexm.com:5432/$%7Bdatabase%7D> " />
                   <property name="username" value="${username}" />
                   <property name="password" value="${password}" />
                   <property name="maxActive" value="32" />
                   <property name="maxIdle" value="5" />
                   <property name="maxWait" value="30000" />
                   <property name="validationQuery" value="select id
from system_settings" />
                   <property name="logAbandoned" value="false" />
                   <property name="timeBetweenEvictionRunsMillis"
value="60000" />
                   <property name="numTestsPerEvictionRun" value="5" />
                   <property name="minEvictableIdleTimeMillis"
value="600000" />
       </dataSource>
   </transactionManager>

   ... my "sqlMap" statements / includes ...
</sqlMapConfig>

Below is some java code that uses it:

Reader reader =
Resources.getResourceAsReader("ibatis_map/echodrive/server/SqlMapConfig.
xml");
try {
   map = SqlMapClientBuilder.buildSqlMapClient(reader,properties);
   map.startTransaction();
   try {
       // Do some selects / updates / inserts

       map.commitTransaction();
   } finally {
       map.endTransaction();
   }
} finally {
   reader.close();
}

If anyone has any ideas, I would appreciate it.

Thanks,
 -- Nathan

 


Re: FW: Connection Closing Problem

Posted by Sundar Sankar <fa...@gmail.com>.
Did u try stepping in through the Ibatis code to see what might actually be
happening when u make the call?

On Tue, Jun 2, 2009 at 1:03 PM, Nathan Modrzewski
<nm...@eaglexm.com>wrote:

> I'm still having problems with this and have not been able to figure it
> out. Anybody have any ideas?
>
> Thanks,
>   -- Nathan
>
> -----Original Message-----
> From: Nathan Modrzewski [mailto:nmodrzewski@eaglexm.com]
> Sent: Saturday, May 30, 2009 4:35 PM
> To: user-java@ibatis.apache.org
> Subject: Connection Closing Problem
>
> I am having a problem with my Postgresql 8.3 connections not being
> closed when the program is finished. Here are a few of the messages from
> the Postgresql log file:
>
> 2009-05-30 16:18:59 MDT [echodrive_machine @ echodrive]: LOG:
> unexpected EOF on client connection
> 2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
> unexpected EOF on client connection
> 2009-05-30 16:19:00 MDT [echodrive_machine @ echodrive]: LOG:
> unexpected EOF on client connection
> 2009-05-30 16:19:02 MDT [echodrive_machine @ echodrive]: LOG:
> unexpected EOF on client connection
>
>
> I'm sure its something I'm doing wrong. I am using Apache Dbcp for my
> connection pooling. I'm using IBatis 2.3.4 and Apache DBCP 1.2.2.
>
> Below is a the xml settings I use for my IBatis and DBCP setup.
>
>
> <sqlMapConfig>
>    <settings
>        useStatementNamespaces="true"
>        cacheModelsEnabled="false"
>        enhancementEnabled="false"
>        lazyLoadingEnabled="false"
>        maxRequests="1024"
>        maxSessions="256"
>        maxTransactions="64"
>    />
>
>    <transactionManager type="JDBC" commitRequired="true">
>            <property name="JDBC.DefaultAutoCommit" value="false" />
>            <property name="JDBC.SetAutoCommitAllowed" value="false" />
>          <dataSource type="DBCP">
>                <property name="driverClassName"
> value="org.postgresql.Driver" />
>                <property name="url"
> value="jdbc:postgresql://db-05.eaglexm.com:5432/${database}<http://db-05.eaglexm.com:5432/$%7Bdatabase%7D>"
> />
>                    <property name="username" value="${username}" />
>                    <property name="password" value="${password}" />
>                    <property name="maxActive" value="32" />
>                    <property name="maxIdle" value="5" />
>                    <property name="maxWait" value="30000" />
>                    <property name="validationQuery" value="select id
> from system_settings" />
>                    <property name="logAbandoned" value="false" />
>                    <property name="timeBetweenEvictionRunsMillis"
> value="60000" />
>                    <property name="numTestsPerEvictionRun" value="5" />
>                    <property name="minEvictableIdleTimeMillis"
> value="600000" />
>        </dataSource>
>    </transactionManager>
>
>    ... my "sqlMap" statements / includes ...
> </sqlMapConfig>
>
> Below is some java code that uses it:
>
> Reader reader =
> Resources.getResourceAsReader("ibatis_map/echodrive/server/SqlMapConfig.
> xml");
> try {
>    map = SqlMapClientBuilder.buildSqlMapClient(reader,properties);
>    map.startTransaction();
>    try {
>        // Do some selects / updates / inserts
>
>        map.commitTransaction();
>    } finally {
>        map.endTransaction();
>    }
> } finally {
>    reader.close();
> }
>
> If anyone has any ideas, I would appreciate it.
>
> Thanks,
>  -- Nathan
>