tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Manzoni <manzoni.alessand...@gmail.com>
Subject Re: connectionProperties is failing?
Date Thu, 23 Oct 2014 12:27:10 GMT
Il 23.10.2014 10.11, Konstantin Kolinko ha scritto:
> 2014-10-23 10:44 GMT+04:00 Alessandro Manzoni <manzoni.alessandro4@gmail.com>:
>> Il 23.10.2014 01.49, Christopher Schultz ha scritto:
>>
>>> On 10/22/14 1:04 PM, Alessandro Manzoni wrote:
>>>> I configured a Resource datasouce inside context.xml but the
>>>> resulting connection is misconfigured.
>>>>
>>>> The failing attribute appears as:
>>>>
>>>> connectionProperties="sort=table;sort table=QSYS/QASCII"
>>>>
>>>> but looking at the connection (while debugging) properties are
>>>> messed up, instead of the above 2 properties I see only 1:
>>>>
>>>> sort=table=QSYS/QASCII
>>>>
>>>> It looks like the property "sort table", with a blank inside the
>>>> name, was not correctly parsed.
>>> It sure does.
>>>
>>>> I'm using jtOpen.jar AS400JDBCDriver that supports a lot of such
>>>> strange property names:
>>>>
>>>> http://www-01.ibm.com/support/knowledgecenter/api/content/ssw_ibm_i_61/rzahh/javadoc/com/ibm/as400/access/doc-files/JDBCProperties.html
>>> Aah,
>>> AS/400. You are a barrel of laughs.
>>>
>>>> If I try supplying the same properties using the
>>>> connect(Properties) method, or appending them to the url, all is
>>>> fine.
>>>>
>>>> Is there some special syntax to achieve my goal?
>>> I think this is likely a bug.
>>>
>>> Whose bug it is depends upon which connection pool you are using. Are
>>> you using Tomcat's default pool (based upon commons-dbcp) or
>>> tomcat-pool. If you don't know, it's probably the former.
>>>
>>> If the bug belongs to commons-dbcp, you should report it over there
>>> and when it gets fixed, we'll consume the changes and then Tomcat
>>> should work properly.
>>>
>>> What version of Tomcat are you using?
>> I did nothing but inserting a <Resource element into context.xml with no
>> factory declared, so I think it's Tomcat's default pool fault:
>>      <Resource name="jdbc/OmniaWebDB2400Pool" auth="Container"
>>          type="javax.sql.DataSource" maxActive="100" maxIdle="30"
>> maxWait="10000"
>>          username="USER" password="PASS"
>>          driverClassName="com.ibm.as400.access.AS400JDBCDriver"
>>          connectionProperties="sort=table;sort table=QSYS/QASCII;"
>>          url="jdbc:as400://dbserver/SCHEMA" />
>>
>>
>> I tried both 6.037 and 7.056 versions with the same result.
>>
>> Itried 8.014 too, but the prgram stops, just while getting the connection
>> from the datasource, datasource.getConnection() method, with this stack
>> trace:
>>
>> java.lang.AbstractMethodError:
>> com.ibm.as400.access.AS400JDBCConnection.isValid(I)Z
>> org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:913)
>> org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:226)
>> org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:302)
>> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2165)
>> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2148)
>> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:1902)
>> org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
>>
>> even if I didn't declare any validate query in datasource definition.
>>
> Default connection pool = Apache Commons DBCP.
>
> Searching Apache Commons DBCP source code for "connectionProperties",
> there a 2 places where that property is parsed:
>
> A) BasicDataSource.setConnectionProperties(String)
>
> It does
> String[] entries = connectionProperties.split(";");
> followed by
> int index = entry.indexOf('=');
>
> It is OK.
>
> B) BasicDataSourceFactory.getProperties(String)
>
> This is an awful undocumented implementation with a bunch of side effects.
>
>      /**
>       * <p>Parse properties from the string. Format of the string must
> be [propertyName=property;]*<p>
>       * @param propText
>       * @return Properties
>       * @throws Exception
>       */
>      private static Properties getProperties(String propText) throws Exception {
>        Properties p = new Properties();
>        if (propText != null) {
>          p.load(new ByteArrayInputStream(
>                  propText.replace(';',
> '\n').getBytes(StandardCharsets.ISO_8859_1)));
>        }
>        return p;
>      }
>
> It replaces ';' with '\n' and feeds the string as ISO-8859-1 into
> Properties.load().  The same implementation of that method is present
> both in current DBCP2 and in previous DBCP 1.4 used by Tomcat 7.
>
> If this implementation is of any use, it must be properly documented.
> As of now, it does not match its own javadoc which only says that
> format is "[propertyName=property;]*". Neither it is documented at
> [2].
>
> The format of a properties file [1] is that
> "The key contains all of the characters in the line starting with the
> first non-white space character and up to, but not including, the
> first unescaped '=', ':', or white space character other than a line
> terminator."
>
> The workaround for you is to escape the whitespace character in key
> name with '\'.
That workaround works fine! In my opinion should be documented inside 
tomcat doc pages.

What do you think about AbstractMethodError problem with tomcat 8?
Am I stuck to version 7, having to use jtOpen jdbc Driver?

Thanks, best regards.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message