tags:

views:

240

answers:

1

Hi,

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("Minimum connections"+connectionNumers.minimum);

Thanks

+2  A: 

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

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.

Example output:

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]

log4j

Peter D