c3p0用于测试连接需要太多时间 [英] c3p0 for testing Connections taking too much time

查看:108
本文介绍了c3p0用于测试连接需要太多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就我而言, 用于测试连接的c3p0通过执行查询花费了太多时间

SHOW FULL TABLES FROM `xyz` LIKE 'PROBABLYNOT'

当我使用mysql连接器版本5.1.25时.有驱动程序支持JDBC 4. 正如我提到的一个链接 http://www.mchange.com/projects/c3p0/#configuring_connection_testing

提到

如果您使用的是JDBC驱动程序,则肯定支持 新的(ish)JDBC 4 API,什么也不做. JDBC 4 Connections包含一个方法 称为isValid(),应实现为快速,可靠的 连接测试.默认情况下,c3p0将使用该方法 礼物.

所以我的问题是我如何知道它使用了isvalid()方法,以及在c3p0调用此方法时执行哪个查询.

解决方案

您显示的查询肯定来自c3p0的慢速默认连接测试.

您正在使用的文档适用于最新版本的c3p0 0.9.5-pre8.您可能没有使用足够新的版本. (我应该在文档中写上说明).

所以...要么升级到0.9.5-pre8(高质量,非常接近发行版),要么提供高效的preferredTestQuery配置参数(SELECT 1似乎适用于MySQL.)

In my case, for testing connection c3p0 is taking too much time by executing query

SHOW FULL TABLES FROM `xyz` LIKE 'PROBABLYNOT'

while i am using mysql connector version 5.1.25. there is driver supports the JDBC 4. as i refered one link http://www.mchange.com/projects/c3p0/#configuring_connection_testing

where it is mentioned that

If you are using a JDBC driver that you are certain supports the new(ish) JDBC 4 API, do nothing. JDBC 4 Connections include a method called isValid() that should be implemented as a fast, reliable Connection test. By default, c3p0 will use that method if it is present.

so my question is how i came to know that it is isvalid() method is used and which query is executed when c3p0 calls this method.

解决方案

The query you've shown definitely derives from c3p0's slow, default Connection test.

The docs you are using are for the latest version of c3p0, 0.9.5-pre8. You may not be using a recent enough version. (I should put a note in the docs indicating this.)

So... either upgrade to 0.9.5-pre8 (it's high quality, very close to release), or supply an efficient preferredTestQuery config param (SELECT 1 seems to work for MySQL.)

这篇关于c3p0用于测试连接需要太多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆