6 Replies Latest reply on Apr 20, 2018 3:16 PM by alkoch

    Embedded quotes prevent use of CLI to add a datasource

    alkoch

      Hello,

       

      I have Wildfly 10 running on Ubuntu 16.04 and I need to use the CLI command line to create a new datasource.  The problem is that the connection-url needs to look like:

      connection-url=jdbc:sqlanywhere:Host=192.168.1.16:14239,192.168.1.16:14251;ServerName=MyServer;

       

      Note that there are two "parts" to the connection-url separated by a semicolon.

       

      If I use the CLI in interactive mode as follows there is no problem:

       

      jboss-cli.sh
      >connect --controller=192.168.1.22:30001
      >/subsystem=datasources/data-source=MyDatasourceID:add(jndi-name=java:jboss/datasources/MyDatasourceID,min-pool-size=1,max-pool-size=5,driver-name=Sybase,connection-url="jdbc:sqlanywhere:Host=192.168.1.16:14239,192.168.1.16:14251;ServerName=MyServer",enabled=true,use-java-context=true,statistics-enabled=true,user-name=,password=

      Note that here I have to enclose the connection-url value in double quotes.

       

      The above works as a test but what I actually need to do is accomplish the above with a single command line such as the following:

       

      jboss-cli.bat --commands="connect --controller=192.168.1.22:30001,/subsystem=datasources/data-source=MyDatasourceID:add(jndi-name=\java:jboss/datasources/MyDatasourceID,min-pool-size=1,max-pool-size=5,driver-name=Sybase,connection-url=\"jdbc:sqlanywhere:Host=192.168.1.16:28889,192.168.1.16:28890;ServerName=MyServer\",enabled=true,use-java-context=true,statistics-enabled=true,user-name=,password="

       

      This fails.  Note that since we are issuing all of this in a single command we have to wrap the value of commands= in double quotes.  But, we already have to wrap connection-url in double quotes.  I originally thought that this would be easily dealt with by escaping the double quotes used in connection-url but that fails.  I have tried every combination of single and double quotes and escaped single and double quotes in various locations and I always get an error message,  Based on what I am trying I get errors like:

       

      'ServerName' is not a valid parameter name.
      '192.168.1.16:14251;ServerName' is not a valid parameter name.

      These errors suggest to me that the parsing is getting confused with the quotes.

       

      I'm sure other's have needed to set a "multi-part" connection-url but I don't see how to get this working.

       

      Is this a bug.  Can someone explain how to do this?

       

      Thank you.

        • 1. Re: Embedded quotes prevent use of CLI to add a datasource
          mayerw01

          So why don't you just replace one double quote (") with an apostrophe (') like

          jboss-cli.bat --commands='connect --controller=192.168.1.22:30001,/subsystem=datasources/data-source=MyDatasourceID:add(jndi-name=\java:jboss/datasources/MyDatasourceID,min-pool-size=1,max-pool-size=5,driver-name=Sybase,connection-url="jdbc:sqlanywhere:Host=192.168.1.16:28889,192.168.1.16:28890;ServerName=MyServer",enabled=true,use-java-context=true,statistics-enabled=true,user-name=,password='

          • 2. Re: Embedded quotes prevent use of CLI to add a datasource
            claudio4j

            You can also escape the quotes \" inside string

            • 3. Re: Embedded quotes prevent use of CLI to add a datasource
              alkoch

              Hi Wolfgang,

               

              Thanks for your suggestion but as I said in my original post that doesn't work.  You might want to see my reply to Claudio below.  Thanks.

              • 4. Re: Embedded quotes prevent use of CLI to add a datasource
                alkoch

                Hi Claudio,

                 

                Thanks for your suggestion but I see that there is a bigger problem here.  I am constructing the CLI command in a Java app and submitting it for execution with:

                Runtime.getRuntime().exec(sCLICmd)

                ;

                 

                Under Windows the command works but under Linux it fails - same command but exec() apparently processes it differently between the two operating systems.  Are you aware of any issues related to this?

                 

                Thanks.

                • 5. Re: Embedded quotes prevent use of CLI to add a datasource
                  mayerw01

                  It looks like MS Windows acts a little bit different. But I think you should move your '--connect' parameter outside the '--comands' parameter.

                  So at least on my Windows7 this command was successful:

                   

                  jboss-cli.bat --connect --controller={ServerName} --commands="/subsystem=datasources/data-source={DSName}:add(jndi-name=java:j

                  boss/datasources/{DSName},driver-name={DriverName},connection-url=\"{UrlName};server={ServerName}\",enabled=true,user-name={userName},password={password}"

                   

                   

                  1 of 1 people found this helpful
                  • 6. Re: Embedded quotes prevent use of CLI to add a datasource
                    alkoch

                    Hi Wolfgang,

                     

                    Thanks for the suggestion.  I see that that works for you under Win 7 but it doesn't help under Ubuntu.  I'm giving up on this because this has taken too long and I found a way to get around it by using a script that contains the commands.  That let's me more forward even though I'd sure like to know what is going on here.

                     

                    Thanks again for the idea.