Re: [BUGS]log can not be output when use DataSource - Mailing list pgsql-jdbc

From Chen Huajun
Subject Re: [BUGS]log can not be output when use DataSource
Date
Msg-id 50FD379F.1020304@cn.fujitsu.com
Whole thread Raw
In response to Re: [BUGS]log can not be output when use DataSource  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: [BUGS]log can not be output when use DataSource
List pgsql-jdbc
> I would not expect it to copy the loglevel property. Why do you expect this behaviour, is there a specification that
youcan refer me to ? 

I have not that specification, i just think it seems to be reasonable since
PgJDBC manual(*1) said it will create a "a new instance with the same settings".

*1)http://jdbc.postgresql.org/documentation/head/jndi.html

In this case,loglevel may not be a good sample, in consideration of it does not be listed in manual(*2),but "ssl" does.

*2)http://jdbc.postgresql.org/documentation/head/ds-cpds.html

Sample for "ssl" looks like that.

-------------------------------------------------
PGPoolingDataSource source = new PGPoolingDataSource();
source.setSsl(true);
initialContext.rebind("DataSource", source);

BaseDataSource source2 = (BaseDataSource) initialContext.lookup("DataSource");
System.out.println(source2.getSsl());//the result is false
-------------------------------------------------


Chen Huajun
(2013/01/21 19:21), Dave Cramer wrote:
>
>
> On Mon, Jan 21, 2013 at 5:27 AM, Chen Huajun <chenhj@cn.fujitsu.com <mailto:chenhj@cn.fujitsu.com>> wrote:
>
>     Hi
>
>
>
>          > If you would create sample code to run to validate both your
>          > bug report and test your patch you may have seen the breakage.
>          > I can tell you that in all cases when DataSource.SetLogLevel(0)
>          > your patch breaks the standard of the user overrides the
>          > Driver.setLogLevel() when it is stipulated.
>          >
>          > I know that valid inputs maybe only be Driver.INFO & Driver.DEBUG,
>          > but if you treat the PgJDBC has a black box which you stimulate
>          > and watch the output then we can not ignore the boundard cases of
>          > <0, 0, & >2.
>
>
>     I made a new patch to avoid the above problem.
>
>
>     But i found a new another problem.
>     In the following code,source2.getConnection() fail to output log as expected.
>     ------------------------------__----------
>     PGPoolingDataSourcesource = new PGPoolingDataSource();
>     source.setLogLevel(2);
>     Connection con = source.getConnection();//OK, log does output
>
>     Properties props = new Properties();
>     props.put(InitialContext.__INITIAL_CONTEXT_FACTORY, "org.postgresql.test.util.__MiniJndiContextFactory");
>     InitialContext initialContext = new InitialContext(props);
>     initialContext.rebind("__DataSource", source);
>
>     BaseDataSource source2 = (BaseDataSource) initialContext.lookup("__DataSource");
>     con = source2.getConnection();//NG, log does not output
>     ------------------------------__----------
>
>     The reason is that loadBaseDataSource(__BaseDataSource ds, Reference ref)
>     fail to copy all properties from ref when source2 was created.
>     So the loglevel of source2 remains to be the defualt value 0.
>     Not only loglevel, some other properties such as "ssl" have the same problem.
>
>
>
> I would not expect it to copy the loglevel property. Why do you expect this behaviour, is there a specification that
youcan refer me to ? 
>
>
>
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca <http://www.credativ.ca/>
>




pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: [BUGS]log can not be output when use DataSource
Next
From: dmp
Date:
Subject: Re: [BUGS]log can not be output when use DataSource