druid,log4j记录sql,发现会执行三次,
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
我访问了一次,从日志看,执行三次sql语句,怎么回事?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
把log4j里面的配置删除,spring里面配置的filter有log类型就可以了,还有就是sql不是执行了3次,而是打印了3遍
先把log中druid的配置去了试试
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters.
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters.
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters.
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed
<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed
同求解决办法
我是在spring里使用的druid,您说的配置是指??
要druid配置
引用来自“echard”的评论
把配置以发出来
把配置以发出来
只配置了proxyFilters,没有filters
是不是同时配置了filter和proxyFilters
#过滤 如果同时配置了filters和proxyFilters,是组合关系,并非替换关系
#filters:config
建议在properties就配置个filters:config,用来加密数据库连接密码。然后在datasource里配置
<!-- 配置监控统计拦截的filters -->
<property name="proxyFilters">
<list>
<ref bean="stat-filter" />
<ref bean="wall-filter" />
<ref bean="log-filter" />
</list>
</property>
引用来自“lgscofield”的评论
应该是log4j配置的问题吧
应该是log4j配置的问题吧
解决没有啊?求分享一下,