X

Proactive insights, news and tips from Oracle WebLogic Server Support. Learn Oracle from Oracle.

Using REST to Create an AGL Data Source

Stephen Felts
Manager

A recent question was raised by a customer on how to create an Active GridLink (AGL) data source using the RESTFUL API's in WebLogic Server (WLS). 

First, you can't do it with the API's provided in WLS release 12.1.3.  New API's were provided starting in WLS 12.2.1 that provide much more complete functionality.  These API's  mirror the MBeans and are more like using WLST.

The following shell script creates an Active GridLink data source using minimal parameters.  You can add more parameters as necessary.  It explicitly sets the data source type, which was new in WLS 12.2.1.  It uses the long-format URL, which is required for AGL. It sets up the SQL query using "ISVALID" to be used for test-connections-on-reserve, which is recommended.  It assumes that auto-ONS is used so no ONS node list is specified.  FAN-enabled must be explicitly set.

c="curl -v --user weblogic:welcome1 -H X-Requested-By:MyClient -H Accept:application/json -H Content-Type:application/json"
localhost=localhost
editurl=http://${localhost}:7001/management/weblogic/latest/edit
name="JDBCGridLinkDataSource"

$c -d "{}" \
 -X POST "${editurl}/changeManager/startEdit"

$c -d "{
    'name': '${name}',
    'targets': [ { identity: [ 'servers', 'myserver' ] } ],
}" \
-X POST "${editurl}/JDBCSystemResources?saveChanges=false"

$c -d "{
    'name': '${name}',
    'datasourceType': 'AGL',
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource"

$c -d "{
        'JNDINames': [ 'jndiName' ]
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCDataSourceParams"

$c -d "{
        'password': 'dbpassword',
        'driverName': 'oracle.jdbc.OracleDriver',
        'url': 'jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbhost)(PORT=dbport))(CONNECT_DATA=(SERVICE_NAME=dbservice)))',
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCDriverParams"

$c -d "{
        name: 'user',
        value: 'dbuser'
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCDriverParams/properties/properties"

$c -d "{
        'testTableName': 'SQL ISVALID'
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCConnectionPoolParams"

$c -d "{
        "fanEnabled":true
}" \
-X POST "${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCOracleParams"

$c -d "{}" \
 -X POST "${editurl}/changeManager/activate"

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.