1
votes

I'm trying to create JDBC provider at cell scope with scripting. I've found in the IBM documentation the way to create the JDBCProvider, but it creates provider at the Node scope:

providerName = 'DB2 Universal JDBC Driver Provider'
providerAttribs = [["xa", "false"], ["providerType", providerName], ['isolatedClassLoader', 'false'], 
['nativepath', '${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}'],
['classpath', '${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar']]
provider = AdminJDBC.createJDBCProvider(nodeName, serverName, providerName, 'com.ibm.db2.jcc.DB2ConnectionPoolDataSource', providerAttribs)

I've read the API for createJDBCProviderAtScope: http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frxml_7adminjdbc.html and I've updated my code:

providerAttribs = [["xa", "false"], ["providerType", providerName], ['isolatedClassLoader', 'false'], 
['nativepath', '${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}'],
['implementationClassName', 'com.ibm.db2.jcc.DB2ConnectionPoolDataSource'],
['classpath', '${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar']]
provider = AdminJDBC.createJDBCProviderAtScope(cell, "DB2", providerName, providerName, 'Connection pool data source', providerAttribs)

But now I get the exception:

Exception: com.ibm.ws.scripting.ScriptingException com.ibm.ws.scripting.ScriptingException: com.ibm.ws.scripting.ScriptingException: com.ibm.websphere.management.cmdframework.CommandNotFoundException: ADMF0006E: Step xa of command createJDBCProvider is not found.

What is the correct way to create JDBCProvider on the cell scope?

1

1 Answers

4
votes

Try this:

providerAttribs = []
providerAttribs.append(["xa", "false"])
providerAttribs.append(['providerType', 'DB2 Universal JDBC Driver Provider']) 
providerAttribs.append(['isolatedClassLoader', 'false'])
providerAttribs.append(['nativepath', '${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}'])
providerAttribs.append(['implementationClassName', 'com.ibm.db2.jcc.DB2ConnectionPoolDataSource'])
providerAttribs.append(['classpath', '${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar'])
providerAttribs.append(['name', 'DB2 Universal JDBC Driver Provider'])
provider = AdminConfig.create("JDBCProvider", AdminConfig.getid('/Cell:/'), providerAttribs)

... I wouldn't be myself if I didn't take this opportunity to advertise WDR library (available at http://wdr.github.io/WDR/)

variables = {}
variables['cellName'] = getid1('/Cell:/').name
loadConfiguration( 'cell_scope_provider.wdrc', variables )

The 'cell_scope_provider.wdrc' referenced above is a file containing configuration manifest:

Cell
    *name $[cellName]
    JDBCProvider
        *name DB2 Universal JDBC Driver Provider
        -xa false
        -providerType DB2 Universal JDBC Driver Provider
        -isolatedClassLoader false
        -nativepath ${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}
        -implementationClassName com.ibm.db2.jcc.DB2ConnectionPoolDataSource
        -classpath ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar