pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chen Huajun <chenhj@cn.fujitsu.com>
To: dmp <danap@ttc-cmc.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [BUGS]log can not be output when use DataSource
Date: Sun, 03 Feb 2013 01:52:07 +0800
Message-ID: <510D5247.5030508@cn.fujitsu.com> (raw)
In-Reply-To: <51080592.5080904@ttc-cmc.net>
References: <50F8335B.6070404@ttc-cmc.net>
	<50FA1403.7020301@cn.fujitsu.com>
	<50FAF98A.1030008@ttc-cmc.net>
	<50FBCA78.3040007@cn.fujitsu.com>
	<50FC3529.3060101@ttc-cmc.net>
	<50FCC7EC.7050307@cn.fujitsu.com>
	<50FD1818.8060002@cn.fujitsu.com>
	<CADK3HHJ71-or6kcrg8YytLJc00ZU6M7LRkAdvqhgK1U1d=EsiA@mail.gmail.com>
	<50FD379F.1020304@cn.fujitsu.com>
	<50FD7094.9050104@ttc-cmc.net>
	<50FFEB3C.5050700@cn.fujitsu.com>
	<51002D8E.9040905@ttc-cmc.net>
	<510660C5.1080801@cn.fujitsu.com>
	<CADK3HHLYUL52uSg37E_0a8R-W-n1V7r0KpwGQ2Hnw__OtQRqCQ@mail.gmail.com>
	<5106BB52.5000203@ttc-cmc.net>
	<51076176.5070800@cn.fujitsu.com>
	<51080592.5080904@ttc-cmc.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hi

I have made a new patch for BaseDataSource ,please check it.
Some modifications in getReference() is just for keeping
the same style to other String parameters .

Chen Huajun
(2013/01/30 1:23), dmp wrote:
>
>  >> dmp wote:
>>> 3. The fourth column Chen in your spreadsheet is usefull in identifying two
>>> properties that are defined in the BaseDataSource but not implemented
>>> in getURL(). The properties user & password are included in getConnection()
>>> and therefore do not not need to be in getURL(). The two not implemented:
>>
>
> Chen Huajun wrote:
>> I advocate user & password also need to be in getURL().
>> Because getURL() is the key way to affect a connection created by the DataSource.
>> If a property not need be included in getURL(),it also seems not needed to appear in BaseDataSource.
>> And just like DriverManager,by which can set user & password via getConnection's arguments or url,
>> DataSource should same to DriverManager.
>>
>> Connection db = DriverManager.getConnection(url, username, password);
>>
>> or
>>
>> String url = "jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true";
>> Connection conn = DriverManager.getConnection(url);
>
> If this is a route you would like to take then that can be included with the
> patch for review. The Java API for the DataSource though only indicates the
> two methods:
>
> Connection getConnection()
> Connection getConnection(String username, String password)
>
> Therefore they must stay. The two additional methods you advocate only make
> more work, but has you say allows more flexibility.
>
> Chen, this project is really short of contributors so any major changes to the
> code must be accompanied by testing on your part. Maintenance seems to be me
> to be the main priority until that changes. That is why since you were familiar
> with the BaseDataSource logLevel bug I asked if you could review, to see if
> there were other similar bugs in that class for the properties.
>
> danap.
>
>
>
>

-- 
Best Regards
--------------------------------------------------
   富士通南大軟件技術有限公司(FNST)
   第二ソフトウェア事業部第三開発部
   陳華軍(チン カグン)
   Addr: 南京富士通南大軟件技術有限公司(FNST)
         中国南京市雨花台区文竹路6号(210012)
   Mail: chenhj@cn.fujitsu.com
   Tel : +86+25-86630566-8406  内線: 7998-8406
   Fax : +86+25-83317685
--------------------------------------------------

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Attachments:

pgjdbc_BaseDataSource.patch (text/plain, 5.7K) download diff --git a/org/postgresql/ds/common/BaseDataSource.java b/org/postgresql/ds/common/BaseDataSource.java index bfe54f7..64cd0be 100644 --- a/org/postgresql/ds/common/BaseDataSource.java +++ b/org/postgresql/ds/common/BaseDataSource.java @@ -43,15 +43,15 @@ // Standard properties, defined in the JDBC 2.0 Optional Package spec private String serverName = "localhost"; - private String databaseName; + private String databaseName = ""; private String user; private String password; private int portNumber = 0; private int prepareThreshold = 5; private int unknownLength = Integer.MAX_VALUE; private boolean binaryTransfer = true; - private String binaryTransferEnable = ""; - private String binaryTransferDisable = ""; + private String binaryTransferEnable; + private String binaryTransferDisable; private int loginTimeout = 0; // in seconds private int socketTimeout = 0; // in seconds private int receiveBufferSize = -1; // off (-1), not in use @@ -63,6 +63,7 @@ private int logLevel = 0; private int protocolVersion = 0; private String applicationName; + private boolean logLevelSet = false; /** * Gets a connection to the PostgreSQL database. The database is identified by the @@ -184,6 +185,7 @@ public void setLogLevel(int logLevel) { this.logLevel = logLevel; + logLevelSet = true; } public int getProtocolVersion() @@ -295,6 +297,14 @@ } /** + * Gets the write buffer size of TCP/IP socket. + */ + public int getReceiveBufferSize() + { + return receiveBufferSize; + } + + /** * Sets the write buffer size of TCP/IP socket. */ public void setReceiveBufferSize(int nbytes) @@ -302,6 +312,14 @@ this.receiveBufferSize = nbytes; } + /** + * Gets the send buffer size of TCP/IP socket. + */ + public int getSendBufferSize() + { + return sendBufferSize; + } + /** * Sets the send buffer size of TCP/IP socket. */ @@ -486,7 +504,15 @@ sb.append("&socketTimeout=").append(socketTimeout); sb.append("&prepareThreshold=").append(prepareThreshold); sb.append("&unknownLength=").append(unknownLength); - sb.append("&loglevel=").append(logLevel); + if(user != null) { + sb.append("&user=").append(user); + } + if(password != null) { + sb.append("&password=").append(password); + } + if (logLevelSet) { + sb.append("&loglevel=").append(logLevel); + } if (protocolVersion != 0) { sb.append("&protocolVersion=").append(protocolVersion); } @@ -510,10 +536,14 @@ sb.append("&ApplicationName="); sb.append(applicationName); } - if (binaryTransfer) { - sb.append("&binaryTransfer=true"); + sb.append("&binaryTransfer").append(binaryTransfer); + if (binaryTransferEnable != null) { + sb.append("&binaryTransferEnable=").append(binaryTransferEnable); } - + if (binaryTransferDisable != null) { + sb.append("&binaryTransferDisable=").append(binaryTransferDisable); + } + return sb.toString(); } @@ -548,11 +578,22 @@ ref.add(new StringRefAddr("prepareThreshold", Integer.toString(prepareThreshold))); ref.add(new StringRefAddr("unknownLength", Integer.toString(unknownLength))); ref.add(new StringRefAddr("binaryTransfer", Boolean.toString(binaryTransfer))); + if (binaryTransferEnable != null) + { + ref.add(new StringRefAddr("binaryTransferEnable", binaryTransferEnable)); + } + if (binaryTransferDisable != null) + { + ref.add(new StringRefAddr("binaryTransferDisable", binaryTransferDisable)); + } ref.add(new StringRefAddr("loginTimeout", Integer.toString(loginTimeout))); ref.add(new StringRefAddr("socketTimeout", Integer.toString(socketTimeout))); ref.add(new StringRefAddr("ssl", Boolean.toString(ssl))); - ref.add(new StringRefAddr("sslfactory", sslfactory)); + if(sslfactory !=null) + { + ref.add(new StringRefAddr("sslfactory", sslfactory)); + } ref.add(new StringRefAddr("receiveBufferSize", Integer.toString(receiveBufferSize))); ref.add(new StringRefAddr("sendBufferSize", Integer.toString(sendBufferSize))); @@ -562,9 +603,15 @@ ref.add(new StringRefAddr("compatible", compatible)); } - ref.add(new StringRefAddr("logLevel", Integer.toString(logLevel))); + if(logLevelSet) + { + ref.add(new StringRefAddr("logLevel", Integer.toString(logLevel))); + } ref.add(new StringRefAddr("protocolVersion", Integer.toString(protocolVersion))); - ref.add(new StringRefAddr("ApplicationName", applicationName)); + if(applicationName != null) + { + ref.add(new StringRefAddr("ApplicationName", applicationName)); + } return ref; } @@ -592,6 +639,7 @@ out.writeBoolean(binaryTransfer); out.writeObject(binaryTransferEnable); out.writeObject(binaryTransferDisable); + out.writeBoolean(logLevelSet); } protected void readBaseObject(ObjectInputStream in) throws IOException, ClassNotFoundException @@ -617,6 +665,7 @@ binaryTransfer = in.readBoolean(); binaryTransferEnable = (String)in.readObject(); binaryTransferDisable = (String)in.readObject(); + logLevelSet = in.readBoolean(); } public void initializeFrom(BaseDataSource source) throws IOException, ClassNotFoundException {=

view thread (30+ messages)  latest in thread

Message-ID: <510D5247.5030508@cn.fujitsu.com>
Permalink:  ../510D5247.5030508@cn.fujitsu.com/
Also on:    postgresql.org/message-id/510D5247.5030508@cn.fujitsu.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: chenhj@cn.fujitsu.com, danap@ttc-cmc.net
  Subject: Re: [BUGS]log can not be output when use DataSource
  In-Reply-To: <510D5247.5030508@cn.fujitsu.com>
  References: <50F8335B.6070404@ttc-cmc.net> <50FA1403.7020301@cn.fujitsu.com> <50FAF98A.1030008@ttc-cmc.net> <50FBCA78.3040007@cn.fujitsu.com> <50FC3529.3060101@ttc-cmc.net> <50FCC7EC.7050307@cn.fujitsu.com> <50FD1818.8060002@cn.fujitsu.com> <CADK3HHJ71-or6kcrg8YytLJc00ZU6M7LRkAdvqhgK1U1d=EsiA@mail.gmail.com> <50FD379F.1020304@cn.fujitsu.com> <50FD7094.9050104@ttc-cmc.net> <50FFEB3C.5050700@cn.fujitsu.com> <51002D8E.9040905@ttc-cmc.net> <510660C5.1080801@cn.fujitsu.com> <CADK3HHLYUL52uSg37E_0a8R-W-n1V7r0KpwGQ2Hnw__OtQRqCQ@mail.gmail.com> <5106BB52.5000203@ttc-cmc.net> <51076176.5070800@cn.fujitsu.com> <51080592.5080904@ttc-cmc.net> <510D5247.5030508@cn.fujitsu.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox