我可以通过编程方式访问c3P0连接池属性吗? [英] Can I access the c3P0 connection pool properties programmatically?
本文介绍了我可以通过编程方式访问c3P0连接池属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我担心为C3P0连接池设置的属性未正确使用。
I am worried that the properties I have set for my C3P0 connection pool are not being used correctly.
有没有办法我可以访问设置的值当应用程序运行并打印出来时:
Is there a way I can access the values that are set while the application is running and print them out:
Println(最小连接数 + connectionNumers.minimum);
Println("Minimum connections"+connectionNumers.minimum);
谢谢
推荐答案
您可以使用log4j输出调试信息,如下所示:
You can use log4j to output debug information like so:
log4j.logger.com.mchange=DEBUG, STDOUT
### direct log messages to stdout ###
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.Target=System.out
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%t %d{dd/MMM/yyyy:H:mm:ssZ} %5p %c{1}:%L - %m%n
如果将以上内容放入名为 log4j.properties
的文件中,然后将该文件放入classpath,您应该从c3p0获得大量调试输出。
If you put the above in a file called log4j.properties
and put that file in your classpath you should get tons of debug output from c3p0.
示例输出:
main 14/Dec/2009:13:24:49-0500 DEBUG BasicResourcePool:289 - com.mchange.v2.resourcepool.BasicResourcePool@16c06dd config: [start -> 0; min -> 0; max -> 5; inc -> 1; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 300000; mox_resource_age -> 0; max_idle_time -> 100000; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 25000; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]
main 14/Dec/2009:13:24:49-0500 DEBUG BasicResourcePool:538 - acquire test -- pool size: 0; target_pool_size: 0; desired target? 1
main 14/Dec/2009:13:24:49-0500 DEBUG BasicResourcePool:404 - incremented pending_acquires: 1
main 14/Dec/2009:13:24:49-0500 DEBUG BasicResourcePool:1291 - awaitAvailable(): [unknown]
这篇关于我可以通过编程方式访问c3P0连接池属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文