postgresqljbossjboss-cli

JBoss CLI escaping SELECT 1


Using JBoss (EAP 6.4) CLI to deploy, and at this point, want to add a datasource.

The cli command is like this

/profile=XXX/subsystem=datasources/data-source=XXX:add\(connection-url=XXX,url-delimiter="|",jndi-name=java:jboss/datasources/XXX,driver-name=postgresql,user-name=XXX,password=XXX,check-valid-connection-sql="SELECT 1",validate-on-match=true,background-validation=false,share-prepared-statements=false\)

The exact add call looks this:

/data-source=${DS_NAME}:add(                     \
      connection-url=${DS_CONNECTION_URL},           \
      jndi-name=${DS_JNDI_NAME},                     \
      driver-name=${DS_DRIVER_NAME},                 \
      user-name=${DB_USER},                          \
      password=${DB_USER_PASSWD},                    \
      check-valid-connection-sql=\"SELECT 1\",       \
      validate-on-match=true,                        \
      background-validation=false,                   \
      share-prepared-statements=false)

Actually only this part is interesting

check-valid-connection-sql="SELECT 1"

After a successfull deployment, the whitespace will be replace with a double apostrophe. This is what I get in the pgsql log:

ERROR: syntax error at or near "1" at character 9
STATEMENT: SELECT''1

The JBoss admin console also shows SELECT''1 in the Configuration -> Datasources -> Validation > Check Valid Sql attribute

Tried to escape it properly several ways, without success. Any idea?


Solution

  • Missed to share the result yet, so:

    JBoss EAP had a bug with the whitespaces, before version 7.1.2.Final (EAP) https://issues.jboss.org/browse/AS7-4263