Wednesday, 18 May 2016

How to create a datasource from the JBoss CLI in JBoss EAP 6

The following post is showing create a datasource from the JBoss CLI in JBoss EAP 6.

High level Steps create a datasource:

1. Deploy the database driver
2. Create the Datasource
3. Test the datasource connection

=================================================================
        Detailed Steps  
=================================================================

1. Deploy the database driver

[domain@192.168.1.12:9999 /] deploy /u01/app/oracle/product/11.1.0/db_1/jdbc/lib/ojdbc6.jar --all-server-groups

2. Create the Datasource from CLI

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa-ds1/:add(jndi-name=java:/jboss/jdbc/rpa1-ds,driver-name=ojdbc6.jar,connection-url=jdbc:oracle:thin:@//middleware.tech.com:1521/orcl,driver-class=oracle.jdbc.OracleDriver,prepared-statements-cache-size=10,password=tiger,max-pool-size=20,track-statements=NOWARN,flush-strategy=FailingConnectionOnly,user-name=scott,idle-timeout-minutes=3,query-timeout=2,min-pool-size=1)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}

}

3. Enable the Datasource

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa-ds1/:enable
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}

}

 I can see the datasource element in domain xml:

<datasource jndi-name="java:/jboss/jdbc/rpa1-ds" pool-name="rpa-ds1" enabled="true">
              <connection-url>jdbc:oracle:thin:@//middleware.tech.com:1521/orcl</connection-url>
                        <driver-class>oracle.jdbc.OracleDriver</driver-class>
                        <driver>ojdbc6.jar</driver>
                        <pool>
                            <min-pool-size>1</min-pool-size>
                            <max-pool-size>20</max-pool-size>
                            <flush-strategy>FailingConnectionOnly</flush-strategy>
                        </pool>
                        <security>
                            <user-name>scott</user-name>
                            <password>tiger</password>
                        </security>
                        <timeout>
                            <idle-timeout-minutes>3</idle-timeout-minutes>
                            <query-timeout>2</query-timeout>
                        </timeout>
                        <statement>
                            <track-statements>NOWARN</track-statements>
                           <prepared-statement-cache-size>10</prepared-statement-cache-size>
                        </statement>
               </datasource>



4. Test the datasource connection

[domain@192.168.1.12:9999 /] /host=slave01/server=rpa1-AS1/subsystem=datasources/data-source=rpa-ds1:test-connection-in-pool
{
    "outcome" => "success",
    "result" => [true]
}

====================================================================


Remove a datasource from the JBoss CLI  

1. Disable the datasource 

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa1-ds/:disable
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}


 2. Remove the datasouce 

[domain@192.168.1.12:9999 /] /profile=rpa1/subsystem=datasources/data-source=rpa1-ds/:remove
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"rpa-group2" => {"host" => {"slave01" => {"rpa1-AS1" => {"response" => {
        "outcome" => "success",
        "result" => undefined,
        "response-headers" => {"process-state" => "restart-required"}
    }}}}}}
}




I hope this information is helpful to you......

 Please register to this blog ...to get alerts when I post new articles or if you have need help in Middleware tasks 

No comments: