users@javaee-spec.java.net

[javaee-spec users] Re: Improving data-source element with facility for vendor specific pool settings?

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Fri, 13 Feb 2015 23:53:59 +0100

Hi,

On Fri, Feb 13, 2015 at 8:33 PM, Bill Shannon <bill.shannon_at_oracle.com> wrote:
> Here's how we expected this to work...
>
> Any property that matches a JavaBeans property on the JDBC vendor's
> DataSource implementation would be set on an instance of that class.
> The rest of the properties, or maybe just all of the properties,
> would be passed to the connection pool implementation to configure
> the connection pool. Nothing other than the connection pool implementation
> needed to know which properties were for the connection pool.
>
> Is there a reason that won't work?

The DataSource implementation is unknown in general. Suppose that my
custom one happens to have a property called "useStrictMin" and that
this just happens to be a property of the pool as well. In that case
how does the implementation know which property to set? Both?
DataSource? Pool? None? Throw exception?

Additionally, I wonder, is it really clear to vendors and users alike
that the general properties can now go to either the pool or the data
source?

I know that IBM 100% gets this (see
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/cdat_datres.html?cp=SSAW57_8.5.5%2F1-3-0-23-3-0-0-3)
but it may be possible that e.g. JBoss just doesn't know this.

See http://grepcode.com/file/repo1.maven.org/maven2/org.wildfly/wildfly-connector/8.2.0.Final/org/jboss/as/connector/deployers/datasource/DirectDataSourceInjectionSource.java#193

From the source it's clear that JBoss compares all properties against
the configured DataSource class, and throws away everything that's not
a property of the DataSource. It doesn't even attempt to set anything
on their pool.

While I know that vendor specific properties themselves are always
non-portable, in the case of the standard and portable data-source
element it means the element can not be used at all with some vendors,
and that the vendor specific way to define data sources must be used.
I wonder if the EE spec can do anything to mitigate this somewhat.

Kind regards,
Arjan Tijms



>
> arjan tijms wrote on 02/09/15 13:37:
>> In Java EE one can use the data-source element in web.xml, ejb-jar.xml
>> and application.xml to define a data source.
>>
>> The Java EE XSD defines a set of standardized properties, and a
>> general property element for vendor specific properties.
>>
>> Though the XSD doesn't separate them in any way, the standardized
>> properties actually belong to two different groups:
>>
>> 1. Properties for the datasource, such as url, user and password
>> 2. Properties for the connection pool, such as initial-pool-size,
>> min-pool-size and max-pool-size
>>
>> The general vendor specific properties via the property element
>> however seem to be intended for the datasource only. There's no
>> element available to set vendor specific properties on the connection
>> pool. In practice there often are such options. Just as an example
>> JBoss has things like:
>>
>> * check-valid-connection-sql
>> * use-strict-min
>> * flush-strategy
>>
>> Etc.
>>
>> Other servers have similar properties for their connection pool and/or
>> other ones.
>>
>> So what about adding a new child element to the data-source element:
>>
>> <pool-property> with the same <name> & <value> child elements as
>> <property> currently has.
>>
>> This new element could then be used to set vendor specific properties
>> on the connection pool.
>>
>> Thoughts?
>>
>> Kind regards,
>> Arjan Tijms
>