2 Replies Latest reply on Apr 28, 2016 4:21 AM by m.ardito

    Create XA datasource with the help of Teiid Admin Api

    praksah

      Could you please guide me to create XA datasource pragmatically by using teiid admin api.

        • 1. Re: Create XA datasource with the help of Teiid Admin Api
          rareddy

          Prakash,

           

          You should be able to use same semantics as the driver based connection for data source, it should work. As in EAP/WildFly the CLi for creation of these is same. You may have to know what properties to set, let me know if does not work with code you tried.

           

          Ramesh..

          • 2. Re: Create XA datasource with the help of Teiid Admin Api
            m.ardito

            Hi Prakash,

            as Ramesh said above it should just be the same (with correct parameters/properties to config them) as regular non-xa datasources.

             

            You can find many examples digging into teiid quickstarts (look for .cli scripts) GitHub - teiid/teiid-quickstarts: Quick starts for Teiid

             

            Eg, this is a basic example for a datasource (note lines could be wrapped):

            /subsystem=datasources/data-source=h2:add(jndi-name=java:/accounts-ds,  enabled=true, use-java-context=true, driver-name=h2, connection-url="jdbc:h2:mem:accounts;INIT=RUNSCRIPT FROM '${jboss.home.dir}/teiidfiles/customer-schema.sql'\;",user-name=sa, password=sa)

            /subsystem=datasources/data-source=h2:enable

             

            (taken from teiid-quickstarts/setup.cli at master · teiid/teiid-quickstarts · GitHub)

             

            You can just create the script, name it something.cli, and then depoloy it using

            <jboss folder>/bin/jboss-cli.sh -c --file=/path/to/the/something.cli

             

            if all ends well, you'll something like a

             

            (success)

             

            output for each script line

             

            You can also use variables in scripts to simplify their management, like (example for non-xa mysql datasource)

            #----------------- something.cli start ------------------------------------------------------------------

            set username=myusername

            set password=mypassord

            set server=jdbc:mysql://1.2.3.4:3306/

            set driverclass=com.mysql.jdbc.Driver

            set driverjar=mysql-connector-java-5.1.22-bin.jar

            set validconnsql="select version();"

            set validonmatch=true

             

            #=========================

            set dsname=mydsname

            set dbname=mydbname

            #=========================

            /subsystem=datasources/data-source=$dsname:add(jndi-name=java:/$dsname, enabled=true, use-java-context=true, driver-class=$driverclass,driver-name=$driverjar,connection-url=$server$dbname,user-name=$username,password=$password,check-valid-connection-sql=$validconnsql,validate-on-match=$validonmatch)

             

            #----------------- something.cli end ------------------------------------------------------------------

             

            I'm currently not using xa datasources, but in the next days I'll try to make one in this way, so that it could be more useful.

             

            hth,

            Marco