You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Anton Rothenbacher (JIRA)" <ib...@incubator.apache.org> on 2007/08/12 18:15:43 UTC

[jira] Created: (IBATIS-449) Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?

Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?
------------------------------------------------------------------------------------------

                 Key: IBATIS-449
                 URL: https://issues.apache.org/jira/browse/IBATIS-449
             Project: iBatis for Java
          Issue Type: Improvement
         Environment: Red Hat Enterprise Linux 4 Update 5 x86-64, JBOSS 4.0.5
            Reporter: Anton Rothenbacher
            Priority: Critical


It seems there is no way to specify a timeout when implementing the Pool.PingQuery to test pooled connections before use. We are in an environment that is closing connections on us and when the app is inactive for a long time, the first connection to be tested out of the pool is bad, and it takes 15 minutes before the connection is deemed bad and the connection recycled.

2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection 2865240 from pool.
2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 2865240 ...
.....
2007-08-11 06:53:40,695 WARN  [com.ibatis.common.jdbc.SimpleDataSource] Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out
2007-08-11 06:53:40,695 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 2865240 is BAD: Io exception: Connection timed out
2007-08-11 06:53:40,696 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] A bad connection (2865240) was returned from the pool, getting another connection.
2007-08-11 06:53:40,750 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 10545003.

This is a problem since the app hangs for the time when it is waiting for the connection. We are looking for a way to speed up the PingQuery test so that if it does not respond in x seconds, (it is a very fast query) then recycle the connection right away, not 15min later when the connection times out.

Here is the relevent section from our SqlMapConfig.xml

    <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
    Notice the use of the properties from the above resource -->
    <transactionManager type="JDBC" commitRequired="true">
        <dataSource type="SIMPLE">
            <property name="JDBC.Driver" value="${driver}"/>
            <property name="JDBC.ConnectionURL" value="${url}"/>
            <property name="JDBC.Username" value="${username}"/>
            <property name="JDBC.Password" value="${password}"/>
            <property name="JDBC.DefaultAutoCommit" value="${jdbc.default.auto.commit}" />
            <property name="Pool.MaximumActiveConnections" value="${pool.maximum.active.connections}"/>
            <property name="Pool.MaximumIdleConnections" value="${pool.maximum.idle.connections}"/>
            <property name="Pool.MaximumCheckoutTime" value="${pool.maximum.checkout.time}"/>
            <property name="Pool.TimeToWait" value="${pool.time.to.wait}"/>
            <property name="Pool.PingQuery" value="select 1 from DUAL"/>
            <property name="Pool.PingEnabled" value="true"/>
            <property name="Pool.PingConnectionsOlderThan" value="1"/>
            <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
        </dataSource>
    </transactionManager>

Is DBCP type connection better for what we wish to accomplish? It seems it can test connections idle connections out of the pool on a regular basis but as far as I can tell SimpleDataSource can only test connections as they are requested out of the pool. Am I correct, does anyone have any suggestions?

Thanks much for your time!



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: When will the IBatis.NET V2 be released?

Posted by Clinton Begin <cl...@gmail.com>.
Keep in mind that the whiteboard is just a guideline and not a hard bound
spec.  I love to see the innovation that the .NET team comes up with.  We
don't want to stifle the opportunities that .NET makes possible that Java
does not allow for, and we also want to learn from Gilles and the others on
their ideas for the future of iBATIS.   For a number of reasons, we should
see iBATIS.NET surpass the success that the Java version has seen.

The iBATIS 3.0 for Java source will be uploaded to Apache SVN soon.
Currently we only have a Java configuration API, but will also be supporting
XML, Annotations (similar to .NET Attributes) and possibly a
convention/generation based configuration.  I'm excited about all of the
changes and want to get them out soon.

Cheers,
Clinton

On Thu, Apr 17, 2008 at 2:20 AM, Gilles Bayon <ib...@gmail.com> wrote:

> The .NE version is also moving to the V3 and you can even more find this
> next version in
>  http://svn.apache.org/repos/asf/ibatis/trunk/cs/V2/
> Don't care to the V2 directory name it will surely be changed to V3.
>
> This version only targets .NET framework >= 2.*
> The main change are:
> - use Castle.DynamicProxy V2
> - Configuration element can be register in any order.
> - Configuration can be made by code (alias, typeHandler, resultMap,
> parameterMap)
> - External resource now follow the .NET standard access used by Spring,
> Castle as
>   <sqlMaps>
>         <sqlMap uri="file://../../${directory}/Mapping1.xml"/>
>          <sqlMap
> uri="assembly://Apache.Ibatis.DataMapper.SqlClient.Test/Maps/Mapping2.xml"/>
>         <sqlMap uri="file://../../Maps/Mapping3.xml"/>
>         <sqlMap uri="file://../../Maps/Mapping4.xml"/>
>         <sqlMap
> uri="assembly://Apache.Ibatis.DataMapper.SqlClient.Test/Maps/Mapping5.xml"/>
>   </sqlMaps>
> - Configuration API change following iBATIS 3.0 Whiteboard
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard
> - iBATIS session access via ISessionFactory
>
> Example:
> /// <summary>
>     /// This module will register the resultMaps under the convention
> namespace Account
>     /// </summary>
>     public class AccountModule : Module
>     {
>
>         public override void Load()
>         {
>             RegisterAlias<Account>();
>
>             RegisterTypeHandler<bool,
> OuiNonBoolTypeHandlerCallback>("Varchar");
>
>             RegisterResultMap<Account>("account-result-nullable-email")
>                 .MappingMember("Id").ToColumnName("Account_ID")
>
> .MappingMember("FirstName").ToColumnName("Account_FirstName")
>
> .MappingMember("LastName").ToColumnName("Account_LastName")
>
> .MappingMember("EmailAddress").ToColumnName("Account_Email");
>
>             RegisterParameterMap<Account>("insert-params")
>                 .MappingMember("Id").ToColumn("Account_ID")
>                 .MappingMember("FirstName").ToColumn("Account_FirstName")
>                 .MappingMember("LastName").ToColumn("Account_LastName")
>
> .MappingMember("EmailAddress").ToColumn("Account_Email").UsingNullValue("
> no_email@provided.com")
>
> .MappingMember("BannerOption").ToColumn("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")
>
> .MappingMember("CartOption").ToColumn("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>();
>
>             RegisterResultMap<Account>("account-result-constructor")
>                 .UsingConstructor
>
> .MappingArgument("identifiant").ToColumnName("Account_ID")
>
> .MappingArgument("firstName").ToColumnName("Account_FirstName")
>
> .MappingArgument("lastName").ToColumnName("Account_LastName")
>
> .MappingMember("EmailAddress").ToColumnName("Account_Email").UsingNullValue("
> no_email@provided.com")
>
> .MappingMember("BannerOption").ToColumnName("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")
>
> .MappingMember("CartOption").ToColumnName("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>();
>
>             RegisterResultMap<Account>("account-result-joined-document")
>                 .MappingMember("id").ToColumnName("Account_ID")
>
> .MappingMember("FirstName").ToColumnName("Account_FirstName")
>
> .MappingMember("LastName").ToColumnName("Account_LastName")
>
> .MappingMember("EmailAddress").ToColumnName("Account_Email").UsingNullValue("
> no_email@provided.com")
>
> .MappingMember("BannerOption").ToColumnName("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")
>
> .MappingMember("CartOption").ToColumnName("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>()
>
> .MappingMember("Document").UsingResultMap("Document.document");
>
>         }
>     }
>
>     /// <summary>
>     /// This module will register the resultMaps under the specified
> namespace Document
>     /// </summary>
>     public class DocumentModule : Module
>     {
>         public DocumentModule()
>             : base("Document")
>         { }
>
>         public override void Load()
>         {
>             RegisterAlias<DocumentCollection>("DocumentCollection");
>
>             RegisterResultMap<Document>("baseDocument")
>                 .MappingMember("Id").ToColumnName("Document_ID")
>                 .MappingMember("Title").ToColumnName("Document_Title");
>
>
> RegisterResultMap<Newspaper>("newspaper").Extends("baseDocument")
>                 .MappingMember("City").ToColumnName("Document_City");
>
>
> RegisterResultMap<Document>("document").Extends("baseDocument")
>                 .MappingMember("Test").ToColumnName("Document_Title")
>                 .WithDiscriminator<string>("Document_Type")
>                 .UsingResultMap("Document.book").ForValue("Book")
>                 .UsingResultMap("newspaper").ForValue("Newspaper");
>
>
> RegisterResultMap<Document>("document-custom-handler").Extends("baseDocument")
>                 .WithDiscriminator<string>("Document_Type")
>                 .WithTypeHandler<CustomInheritance>()
>                 .UsingResultMap("book").ForValue("Book")
>                 .UsingResultMap("newspaper").ForValue("Newspaper");
>
>             RegisterResultMap<Book>("book").Extends("document")
>
> .MappingMember("PageNumber").ToColumnName("Document_PageNumber");
>         }
>     }
>
> and you configure the stuff like that
>
>                 string resource = "SqlMap_StatementOnly.config";
>                 IConfigurationEngine engine = new
> DefaultConfigurationEngine();
>                 engine.RegisterInterpreter(new
> XmlConfigurationInterpreter(resource));
>                 engine.RegisterModule(new AccountModule());
>                 engine.RegisterModule(new DocumentModule());
>
>                 IMapperFactory mapperFactory =
> engine.BuildMapperFactory();
>
>                 dataMapper =
> ((IDataMapperAccessor)mapperFactory).DataMapper;
>                 ISessionFactory sessionFactory =
> engine.ModelStore.SessionFactory;
>
>                 dataMapper.Insert("InsertAccountViaParameterMap",
> account);
>
> It's not implemented Annotation support nor the auto-generated interface
> as presented in the Whiteboard for now.
>
> I used it with success :-)
> See unit test for others uses.
>
> --
> Cheers,
> Gilles
>

Re: When will the IBatis.NET V2 be released?

Posted by Gilles Bayon <ib...@gmail.com>.
The .NE version is also moving to the V3 and you can even more find this
next version in
 http://svn.apache.org/repos/asf/ibatis/trunk/cs/V2/
Don't care to the V2 directory name it will surely be changed to V3.

This version only targets .NET framework >= 2.*
The main change are:
- use Castle.DynamicProxy V2
- Configuration element can be register in any order.
- Configuration can be made by code (alias, typeHandler, resultMap,
parameterMap)
- External resource now follow the .NET standard access used by Spring,
Castle as
  <sqlMaps>
        <sqlMap uri="file://../../${directory}/Mapping1.xml"/>
        <sqlMap
uri="assembly://Apache.Ibatis.DataMapper.SqlClient.Test/Maps/Mapping2.xml"/>
        <sqlMap uri="file://../../Maps/Mapping3.xml"/>
        <sqlMap uri="file://../../Maps/Mapping4.xml"/>
        <sqlMap
uri="assembly://Apache.Ibatis.DataMapper.SqlClient.Test/Maps/Mapping5.xml"/>
  </sqlMaps>
- Configuration API change following iBATIS 3.0 Whiteboard
http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard
- iBATIS session access via ISessionFactory

Example:
/// <summary>
    /// This module will register the resultMaps under the convention
namespace Account
    /// </summary>
    public class AccountModule : Module
    {

        public override void Load()
        {
            RegisterAlias<Account>();

            RegisterTypeHandler<bool,
OuiNonBoolTypeHandlerCallback>("Varchar");

            RegisterResultMap<Account>("account-result-nullable-email")
                .MappingMember("Id").ToColumnName("Account_ID")

.MappingMember("FirstName").ToColumnName("Account_FirstName")
                .MappingMember("LastName").ToColumnName("Account_LastName")

.MappingMember("EmailAddress").ToColumnName("Account_Email");

            RegisterParameterMap<Account>("insert-params")
                .MappingMember("Id").ToColumn("Account_ID")
                .MappingMember("FirstName").ToColumn("Account_FirstName")
                .MappingMember("LastName").ToColumn("Account_LastName")

.MappingMember("EmailAddress").ToColumn("Account_Email").UsingNullValue("
no_email@provided.com")

.MappingMember("BannerOption").ToColumn("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")

.MappingMember("CartOption").ToColumn("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>();

            RegisterResultMap<Account>("account-result-constructor")
                .UsingConstructor

.MappingArgument("identifiant").ToColumnName("Account_ID")

.MappingArgument("firstName").ToColumnName("Account_FirstName")

.MappingArgument("lastName").ToColumnName("Account_LastName")

.MappingMember("EmailAddress").ToColumnName("Account_Email").UsingNullValue("
no_email@provided.com")

.MappingMember("BannerOption").ToColumnName("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")

.MappingMember("CartOption").ToColumnName("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>();

            RegisterResultMap<Account>("account-result-joined-document")
                .MappingMember("id").ToColumnName("Account_ID")

.MappingMember("FirstName").ToColumnName("Account_FirstName")
                .MappingMember("LastName").ToColumnName("Account_LastName")

.MappingMember("EmailAddress").ToColumnName("Account_Email").UsingNullValue("
no_email@provided.com")

.MappingMember("BannerOption").ToColumnName("Account_Banner_Option").UsingDbType("Varchar").UsingType("bool")

.MappingMember("CartOption").ToColumnName("Account_Cart_Option").WithTypeHandler<HundredsTypeHandlerCallback>()

.MappingMember("Document").UsingResultMap("Document.document");

        }
    }

    /// <summary>
    /// This module will register the resultMaps under the specified
namespace Document
    /// </summary>
    public class DocumentModule : Module
    {
        public DocumentModule()
            : base("Document")
        { }

        public override void Load()
        {
            RegisterAlias<DocumentCollection>("DocumentCollection");

            RegisterResultMap<Document>("baseDocument")
                .MappingMember("Id").ToColumnName("Document_ID")
                .MappingMember("Title").ToColumnName("Document_Title");


RegisterResultMap<Newspaper>("newspaper").Extends("baseDocument")
                .MappingMember("City").ToColumnName("Document_City");

            RegisterResultMap<Document>("document").Extends("baseDocument")
                .MappingMember("Test").ToColumnName("Document_Title")
                .WithDiscriminator<string>("Document_Type")
                .UsingResultMap("Document.book").ForValue("Book")
                .UsingResultMap("newspaper").ForValue("Newspaper");


RegisterResultMap<Document>("document-custom-handler").Extends("baseDocument")
                .WithDiscriminator<string>("Document_Type")
                .WithTypeHandler<CustomInheritance>()
                .UsingResultMap("book").ForValue("Book")
                .UsingResultMap("newspaper").ForValue("Newspaper");

            RegisterResultMap<Book>("book").Extends("document")

.MappingMember("PageNumber").ToColumnName("Document_PageNumber");
        }
    }

and you configure the stuff like that

                string resource = "SqlMap_StatementOnly.config";
                IConfigurationEngine engine = new
DefaultConfigurationEngine();
                engine.RegisterInterpreter(new
XmlConfigurationInterpreter(resource));
                engine.RegisterModule(new AccountModule());
                engine.RegisterModule(new DocumentModule());

                IMapperFactory mapperFactory = engine.BuildMapperFactory();

                dataMapper =
((IDataMapperAccessor)mapperFactory).DataMapper;
                ISessionFactory sessionFactory =
engine.ModelStore.SessionFactory;

                dataMapper.Insert("InsertAccountViaParameterMap", account);

It's not implemented Annotation support nor the auto-generated interface as
presented in the Whiteboard for now.

I used it with success :-)
See unit test for others uses.

-- 
Cheers,
Gilles

When will the IBatis.NET V2 be released?

Posted by smartkid <sk...@gmail.com>.
Hi,

	The java version is moving to V3 while the .NET version is still staying V1.x.
	Is there any schedule to release a new version of IBatis.NET?

Thanks

Yaojian



[jira] Commented: (IBATIS-449) Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?

Posted by "Anton Rothenbacher (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598372#action_12598372 ] 

Anton Rothenbacher commented on IBATIS-449:
-------------------------------------------

Hi Gerhard, is this patch publicly available? 

What has been the result of using the patch in your environment? 

I think you are saying that the timeout is now configurable and running in a new thread and once the specified timeout threshold is exceeded the connection is deemed bad and immediately recycled thereafter. Is that correct?

Thank you --Anton

> Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?
> ------------------------------------------------------------------------------------------
>
>                 Key: IBATIS-449
>                 URL: https://issues.apache.org/jira/browse/IBATIS-449
>             Project: iBatis for Java
>          Issue Type: Improvement
>         Environment: Red Hat Enterprise Linux 4 Update 5 x86-64, JBOSS 4.0.5
>            Reporter: Anton Rothenbacher
>            Priority: Critical
>
> It seems there is no way to specify a timeout when implementing the Pool.PingQuery to test pooled connections before use. We are in an environment that is closing connections on us and when the app is inactive for a long time, the first connection to be tested out of the pool is bad, and it takes 15 minutes before the connection is deemed bad and the connection recycled.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection 2865240 from pool.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 2865240 ...
> .....
> 2007-08-11 06:53:40,695 WARN  [com.ibatis.common.jdbc.SimpleDataSource] Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out
> 2007-08-11 06:53:40,695 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 2865240 is BAD: Io exception: Connection timed out
> 2007-08-11 06:53:40,696 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] A bad connection (2865240) was returned from the pool, getting another connection.
> 2007-08-11 06:53:40,750 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 10545003.
> This is a problem since the app hangs for the time when it is waiting for the connection. We are looking for a way to speed up the PingQuery test so that if it does not respond in x seconds, (it is a very fast query) then recycle the connection right away, not 15min later when the connection times out.
> Here is the relevent section from our SqlMapConfig.xml
>     <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
>     Notice the use of the properties from the above resource -->
>     <transactionManager type="JDBC" commitRequired="true">
>         <dataSource type="SIMPLE">
>             <property name="JDBC.Driver" value="${driver}"/>
>             <property name="JDBC.ConnectionURL" value="${url}"/>
>             <property name="JDBC.Username" value="${username}"/>
>             <property name="JDBC.Password" value="${password}"/>
>             <property name="JDBC.DefaultAutoCommit" value="${jdbc.default.auto.commit}" />
>             <property name="Pool.MaximumActiveConnections" value="${pool.maximum.active.connections}"/>
>             <property name="Pool.MaximumIdleConnections" value="${pool.maximum.idle.connections}"/>
>             <property name="Pool.MaximumCheckoutTime" value="${pool.maximum.checkout.time}"/>
>             <property name="Pool.TimeToWait" value="${pool.time.to.wait}"/>
>             <property name="Pool.PingQuery" value="select 1 from DUAL"/>
>             <property name="Pool.PingEnabled" value="true"/>
>             <property name="Pool.PingConnectionsOlderThan" value="1"/>
>             <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
>         </dataSource>
>     </transactionManager>
> Is DBCP type connection better for what we wish to accomplish? It seems it can test connections idle connections out of the pool on a regular basis but as far as I can tell SimpleDataSource can only test connections as they are requested out of the pool. Am I correct, does anyone have any suggestions?
> Thanks much for your time!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (IBATIS-449) Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/IBATIS-449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Clinton Begin closed IBATIS-449.
--------------------------------

    Resolution: Invalid

> Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?
> ------------------------------------------------------------------------------------------
>
>                 Key: IBATIS-449
>                 URL: https://issues.apache.org/jira/browse/IBATIS-449
>             Project: iBatis for Java
>          Issue Type: Improvement
>         Environment: Red Hat Enterprise Linux 4 Update 5 x86-64, JBOSS 4.0.5
>            Reporter: Anton Rothenbacher
>            Priority: Critical
>         Attachments: SimpleDataSource.java
>
>
> It seems there is no way to specify a timeout when implementing the Pool.PingQuery to test pooled connections before use. We are in an environment that is closing connections on us and when the app is inactive for a long time, the first connection to be tested out of the pool is bad, and it takes 15 minutes before the connection is deemed bad and the connection recycled.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection 2865240 from pool.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 2865240 ...
> .....
> 2007-08-11 06:53:40,695 WARN  [com.ibatis.common.jdbc.SimpleDataSource] Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out
> 2007-08-11 06:53:40,695 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 2865240 is BAD: Io exception: Connection timed out
> 2007-08-11 06:53:40,696 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] A bad connection (2865240) was returned from the pool, getting another connection.
> 2007-08-11 06:53:40,750 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 10545003.
> This is a problem since the app hangs for the time when it is waiting for the connection. We are looking for a way to speed up the PingQuery test so that if it does not respond in x seconds, (it is a very fast query) then recycle the connection right away, not 15min later when the connection times out.
> Here is the relevent section from our SqlMapConfig.xml
>     <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
>     Notice the use of the properties from the above resource -->
>     <transactionManager type="JDBC" commitRequired="true">
>         <dataSource type="SIMPLE">
>             <property name="JDBC.Driver" value="${driver}"/>
>             <property name="JDBC.ConnectionURL" value="${url}"/>
>             <property name="JDBC.Username" value="${username}"/>
>             <property name="JDBC.Password" value="${password}"/>
>             <property name="JDBC.DefaultAutoCommit" value="${jdbc.default.auto.commit}" />
>             <property name="Pool.MaximumActiveConnections" value="${pool.maximum.active.connections}"/>
>             <property name="Pool.MaximumIdleConnections" value="${pool.maximum.idle.connections}"/>
>             <property name="Pool.MaximumCheckoutTime" value="${pool.maximum.checkout.time}"/>
>             <property name="Pool.TimeToWait" value="${pool.time.to.wait}"/>
>             <property name="Pool.PingQuery" value="select 1 from DUAL"/>
>             <property name="Pool.PingEnabled" value="true"/>
>             <property name="Pool.PingConnectionsOlderThan" value="1"/>
>             <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
>         </dataSource>
>     </transactionManager>
> Is DBCP type connection better for what we wish to accomplish? It seems it can test connections idle connections out of the pool on a regular basis but as far as I can tell SimpleDataSource can only test connections as they are requested out of the pool. Am I correct, does anyone have any suggestions?
> Thanks much for your time!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ibatis.apache.org
For additional commands, e-mail: dev-help@ibatis.apache.org


[jira] Commented: (IBATIS-449) Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?

Posted by "Gerhard Kersten (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589447#action_12589447 ] 

Gerhard Kersten commented on IBATIS-449:
----------------------------------------

Actually DBCP has the same problem.

I have now written a small patch, executing the ping in a separate thead and waiting for it only some finite extent of time.

Note that  realConn.createStatement() is the first statement to hang, and conn.getRealConnection().close() is the last one.

> Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?
> ------------------------------------------------------------------------------------------
>
>                 Key: IBATIS-449
>                 URL: https://issues.apache.org/jira/browse/IBATIS-449
>             Project: iBatis for Java
>          Issue Type: Improvement
>         Environment: Red Hat Enterprise Linux 4 Update 5 x86-64, JBOSS 4.0.5
>            Reporter: Anton Rothenbacher
>            Priority: Critical
>
> It seems there is no way to specify a timeout when implementing the Pool.PingQuery to test pooled connections before use. We are in an environment that is closing connections on us and when the app is inactive for a long time, the first connection to be tested out of the pool is bad, and it takes 15 minutes before the connection is deemed bad and the connection recycled.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection 2865240 from pool.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 2865240 ...
> .....
> 2007-08-11 06:53:40,695 WARN  [com.ibatis.common.jdbc.SimpleDataSource] Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out
> 2007-08-11 06:53:40,695 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 2865240 is BAD: Io exception: Connection timed out
> 2007-08-11 06:53:40,696 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] A bad connection (2865240) was returned from the pool, getting another connection.
> 2007-08-11 06:53:40,750 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 10545003.
> This is a problem since the app hangs for the time when it is waiting for the connection. We are looking for a way to speed up the PingQuery test so that if it does not respond in x seconds, (it is a very fast query) then recycle the connection right away, not 15min later when the connection times out.
> Here is the relevent section from our SqlMapConfig.xml
>     <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
>     Notice the use of the properties from the above resource -->
>     <transactionManager type="JDBC" commitRequired="true">
>         <dataSource type="SIMPLE">
>             <property name="JDBC.Driver" value="${driver}"/>
>             <property name="JDBC.ConnectionURL" value="${url}"/>
>             <property name="JDBC.Username" value="${username}"/>
>             <property name="JDBC.Password" value="${password}"/>
>             <property name="JDBC.DefaultAutoCommit" value="${jdbc.default.auto.commit}" />
>             <property name="Pool.MaximumActiveConnections" value="${pool.maximum.active.connections}"/>
>             <property name="Pool.MaximumIdleConnections" value="${pool.maximum.idle.connections}"/>
>             <property name="Pool.MaximumCheckoutTime" value="${pool.maximum.checkout.time}"/>
>             <property name="Pool.TimeToWait" value="${pool.time.to.wait}"/>
>             <property name="Pool.PingQuery" value="select 1 from DUAL"/>
>             <property name="Pool.PingEnabled" value="true"/>
>             <property name="Pool.PingConnectionsOlderThan" value="1"/>
>             <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
>         </dataSource>
>     </transactionManager>
> Is DBCP type connection better for what we wish to accomplish? It seems it can test connections idle connections out of the pool on a regular basis but as far as I can tell SimpleDataSource can only test connections as they are requested out of the pool. Am I correct, does anyone have any suggestions?
> Thanks much for your time!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IBATIS-449) Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?

Posted by "Gerhard Kersten (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587977#action_12587977 ] 

Gerhard Kersten commented on IBATIS-449:
----------------------------------------

For us it's the same, and it's really mission-critical.

Background: A firewall cuts a TCP connection after some time, but does not close it. With "Ping enabled" iBatis waits forever (actually 943 s) for the ping. Wihout "Ping enabled" a SQLException is thrown (Time out in rollback), also not earlier than after some 900 s. Setting "sun.net.client.defaultReadTimeout=60000" does not help. Here an example with a simulated TCP delay of 600s (against sun.net.client.defaultReadTimeout=60s):
04-11@15:42:03 DEBUG     - Testing connection 27114948...
04-11@15:52:03 DEBUG     - Connection 27114948 is GOOD!

Setting maximumIdleConnections=0 as last hope is no option either, as it slows down everything significantly.

For Bea Datasources I have observed the same firewall problem, but there the ping request returns almost immerdiatly, even for a corrupted TCP connection. Maybe some solution with a separate watchguard thread?


> Is there a way to specify a timeout for Pool.PingQuery when using a jdbc SimpleDataSource?
> ------------------------------------------------------------------------------------------
>
>                 Key: IBATIS-449
>                 URL: https://issues.apache.org/jira/browse/IBATIS-449
>             Project: iBatis for Java
>          Issue Type: Improvement
>         Environment: Red Hat Enterprise Linux 4 Update 5 x86-64, JBOSS 4.0.5
>            Reporter: Anton Rothenbacher
>            Priority: Critical
>
> It seems there is no way to specify a timeout when implementing the Pool.PingQuery to test pooled connections before use. We are in an environment that is closing connections on us and when the app is inactive for a long time, the first connection to be tested out of the pool is bad, and it takes 15 minutes before the connection is deemed bad and the connection recycled.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Checked out connection 2865240 from pool.
> 2007-08-11 06:38:14,032 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Testing connection 2865240 ...
> .....
> 2007-08-11 06:53:40,695 WARN  [com.ibatis.common.jdbc.SimpleDataSource] Execution of ping query 'select 1 from DUAL' failed: Io exception: Connection timed out
> 2007-08-11 06:53:40,695 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Connection 2865240 is BAD: Io exception: Connection timed out
> 2007-08-11 06:53:40,696 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] A bad connection (2865240) was returned from the pool, getting another connection.
> 2007-08-11 06:53:40,750 DEBUG [com.ibatis.common.jdbc.SimpleDataSource] Created connection 10545003.
> This is a problem since the app hangs for the time when it is waiting for the connection. We are looking for a way to speed up the PingQuery test so that if it does not respond in x seconds, (it is a very fast query) then recycle the connection right away, not 15min later when the connection times out.
> Here is the relevent section from our SqlMapConfig.xml
>     <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
>     Notice the use of the properties from the above resource -->
>     <transactionManager type="JDBC" commitRequired="true">
>         <dataSource type="SIMPLE">
>             <property name="JDBC.Driver" value="${driver}"/>
>             <property name="JDBC.ConnectionURL" value="${url}"/>
>             <property name="JDBC.Username" value="${username}"/>
>             <property name="JDBC.Password" value="${password}"/>
>             <property name="JDBC.DefaultAutoCommit" value="${jdbc.default.auto.commit}" />
>             <property name="Pool.MaximumActiveConnections" value="${pool.maximum.active.connections}"/>
>             <property name="Pool.MaximumIdleConnections" value="${pool.maximum.idle.connections}"/>
>             <property name="Pool.MaximumCheckoutTime" value="${pool.maximum.checkout.time}"/>
>             <property name="Pool.TimeToWait" value="${pool.time.to.wait}"/>
>             <property name="Pool.PingQuery" value="select 1 from DUAL"/>
>             <property name="Pool.PingEnabled" value="true"/>
>             <property name="Pool.PingConnectionsOlderThan" value="1"/>
>             <property name="Pool.PingConnectionsNotUsedFor" value="1"/>
>         </dataSource>
>     </transactionManager>
> Is DBCP type connection better for what we wish to accomplish? It seems it can test connections idle connections out of the pool on a regular basis but as far as I can tell SimpleDataSource can only test connections as they are requested out of the pool. Am I correct, does anyone have any suggestions?
> Thanks much for your time!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.