0 Replies Latest reply on Oct 23, 2012 9:52 AM by Nabeel Ahmed

    Create/Update Data source with custom properties, using Native Mangement api.

    Nabeel Ahmed Newbie

      HI Everyone!

       

      I have been using Jboss 7.1.1 Final release and been able to create/remove/list datasources using Native Management API.

       

      Now i want to add some custom properties into the data source i.e.

       

      ModelNode request = new ModelNode();

                          request.get(ClientConstants.OP).set(ClientConstants.ADD);

                          request.get(ClientConstants.OP_ADDR).add("subsystem", "datasources");

                          request.get(ClientConstants.OP_ADDR).add("data-source", "dsName");

                          request.get("jndi-name").set("jndiName");

                          request.get("pool-name").set("pool_Name");

                          request.get("connection-url").set(url);

       

      // custom properties that i want to add

      <connection-property name="propertyName">Value</connection-property>

      <connection-property name="propertyName">Value</connection-property>

      <connection-property name="propertyName">Value</connection-property>

       

                          request.get("driver-name").set(driverName);

                          request.get("user-name").set(username);

                          request.get("password").set(password);

       

       

       

                          ModelControllerClient client = createClient( InetAddress.getByName("127.0.0.1"), 9999, "nabeel", "dsds", "");

                          client.execute(new OperationBuilder(request).build());

                          client.close();

       

      Result would be:

       

        <datasource jta="true" jndi-name="java:/DICTIOANRY/PH" pool-name="dictionary" enabled="true" use-java-context="true" spy="true" use-ccm="true">

                 <connection-url>jdbc:scwapi:client_id=dsds</connection-url>

             <connection-property name="server_path">//jee:127.0.0.1:4447/jee_powerhub</connection-property>

             <connection-property name="IS_DATA_SERVER">true</connection-property>

             <connection-property name="ph_user">user</connection-property>

             <connection-property name="ph_password">password</connection-property>

              <driver>phub</driver>

      </datasource>

       

       

      How can i add these custom properties?

      What code changes required to update existing datasource as the update operation is not available?