Re: connectionProperties is failing?

2014-10-23 Thread Alessandro Manzoni

Il 23.10.2014 01.49, Christopher Schultz ha scritto:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Alessandro,

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=1

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.

Basing upon AS400JDBCConnection docs, it's implementing 
java.sql.Connection interface from JDK 1.4.2, where there was no 
isValid() method.
Maybe this is possibly a bug too, in the sense that 
org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory could take in 
account the driver version before validating it, or cathing 
AbstractMethodError, that's telling that the method is not there.

By the way I cannot test tomcat 8.014 at all.

Thanks + best regards.


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



Re: connectionProperties is failing?

2014-10-23 Thread Konstantin Kolinko
2014-10-23 10:44 GMT+04:00 Alessandro Manzoni manzoni.alessand...@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=1
 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.

/**
 * pParse 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 '\'.


[1] 
http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load%28java.io.Reader%29
[2] http://commons.apache.org/proper/commons-dbcp/configuration.html

Best regards,
Konstantin Kolinko


Re: connectionProperties is failing?

2014-10-23 Thread Alessandro Manzoni

Il 23.10.2014 10.11, Konstantin Kolinko ha scritto:

2014-10-23 10:44 GMT+04:00 Alessandro Manzoni manzoni.alessand...@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=1
 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.

 /**
  * pParse 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, 

Re: connectionProperties is failing?

2014-10-23 Thread Mark Thomas
On 23/10/2014 13:27, Alessandro Manzoni wrote:

 What do you think about AbstractMethodError problem with tomcat 8?

Set testOnBorrow=false

 Am I stuck to version 7, having to use jtOpen jdbc Driver?

No.

Mark


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



connectionProperties is failing?

2014-10-22 Thread Alessandro Manzoni

Hi,
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.


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 



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?

Thanks + kind regards.



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



Re: connectionProperties is failing?

2014-10-22 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Alessandro,

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?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUSEJ4AAoJEBzwKT+lPKRYdkgQALYbanCsf4ItTzg7iLfoqeFd
4/vH/n/l5JuIKf/ImsD6hFxR3WKBXLjwVvFymW7p70AqtAltZav76TwI7E6Mm3yG
O+i7NwVdjloi+/W93khHuLoKI6iQQy1TdnN6IaAT5qTabAjeTP8G1h5H7rDuRTsQ
O3dcU3Wbmmpqikg9Lo5qToycl4qkTfp8+hnw/oh8E6fokDb6hTbXy5/nq4iTuRs8
YnnDSFm+LTmFZgeWoTuyCJSq8AHOc+y0r/HsUqGHiQbGBPRglBhG+6rq9WXV5DVc
pPmdpJS7JzYFpOym5Wlv8mQlYfcHzDjZmJ/6FOuuIE5Iq7KOZBeE9QGooR/85d5b
2Gl5hSBHhzEDBJXhaWFXUM/L/85wqYCaymjDsEOUkzgFjeCjsPKY4vEfu9oM7qdF
xE5NuonpItK8sKfY/aOtfMiP8MRb9Yw7eHJQ3wgyR1OFxHiMTXSvZT39sEfZu0Qv
Jw80ucHhvoJf3VJ526CHl59yv7zxI8i3x+V+5VVP7Y5wqlYxjITDuZlDGJqkIcEI
vlDJ2gNzkg6hKZ13tbhPFsNRp67FDr0ehE9LzeEMHrFyLS8qUi4m7YXmvtm9gS1J
aOJo6gei0xYe4dwaUOSiMIQEzLJDe1yrnl5gvev9hCDWsiv5Eidlr8EAP89O8LLL
qT3YqSnrvZvpbr7REkws
=NYS1
-END PGP SIGNATURE-

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