testConnectionOnCheckout not working when provided as Property

View: New views
2 Messages — Rating Filter:   Alert me  

testConnectionOnCheckout not working when provided as Property

by chrismfwrd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I want to keep all my configuration together in one file and therefor
try to configure c3p0 via
ComboPooledDataSource cpds.setProperties(Properties prop).

This seems to work, e.g. I can do prop.setProperty("user", "myuser");
and this user is taken, however, if I do
prop.setProperty("testConnectionOnCheckout", "true"); this doesn't
seem to be recognized. I want my application to be blocked at
cpds.getConnection() until a connection is available, but it doesn't
block even if the DB isn't available, returning me an "invalid"
connection.
It does work as I would expect when I set this flag directly via
cpds.setTestConnectionOnCheckout(true);


Is this a bug or am I doing / understanding something wrong?

thanks & best regards,
christian!

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
c3p0-users mailing list
c3p0-users@...
https://lists.sourceforge.net/lists/listinfo/c3p0-users

Re: testConnectionOnCheckout not working when provided as Property

by Steve Waldman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian,

The properties that are set by getProperties() are the Properties  
object that gets passed to DriverManager.getConnection(String url,  
Properties props) when a Connection is acquired from the database. So  
it only affects Connnection acquistion properties like user and  
password. It's necessary because some drivers allow vendor-specific  
properties to be set upon Connection acquisition, so setting only user  
and password is not sufficient.

I'd never thought of this, but it is a bit confusing... it might be  
worth renaming.

If you want a unified interface to setting properties (e.g. if you  
want to load properties from a custom config file to generate a c3p0  
data source), you can use...

DataSources.pooledDataSource(DataSource unpooledDataSource, Map  
overrideProps)

Alternatively, there are facilities buried in c3p0 to set the  
properties of a concrete ComboPooledDataSource from a Map, but those  
aren't documented (though they're unlikely to change incompatibly).

      smiles,
          Steve



On Jun 9, 2009, at 4:53 PM, Christian Migowski wrote:

> Hi,
>
> I want to keep all my configuration together in one file and therefor
> try to configure c3p0 via
> ComboPooledDataSource cpds.setProperties(Properties prop).
>
> This seems to work, e.g. I can do prop.setProperty("user", "myuser");
> and this user is taken, however, if I do
> prop.setProperty("testConnectionOnCheckout", "true"); this doesn't
> seem to be recognized. I want my application to be blocked at
> cpds.getConnection() until a connection is available, but it doesn't
> block even if the DB isn't available, returning me an "invalid"
> connection.
> It does work as I would expect when I set this flag directly via
> cpds.setTestConnectionOnCheckout(true);
>
>
> Is this a bug or am I doing / understanding something wrong?
>
> thanks & best regards,
> christian!
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> c3p0-users mailing list
> c3p0-users@...
> https://lists.sourceforge.net/lists/listinfo/c3p0-users

~oo~
Steve Waldman
swaldman@...




------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
c3p0-users mailing list
c3p0-users@...
https://lists.sourceforge.net/lists/listinfo/c3p0-users