使用wsadmin为DB2提供程序创建DataSource(Websphere Application Server 8



我有一个脚本,它使用Websphere Application Server 8.5中的DB2 JDBC Provider创建数据源。所以我在运行脚本时遇到了一个错误,我需要一些帮助。

我的脚本:

def createDB2(list):
    print 'Creating DB2 Data Source...'
    for dataSource in list:
        datasourceName=dataSource[0]
        dsJNDIName=dataSource[1]
        compAuthAlias=dataSource[2]
        providerName=dataSource[3]
        dataStoreHelperClassName=dataSource[4]
        description=dataSource[5]
        serverName=dataSource[6]
        databaseMaxConnections=dataSource[7]
        databaseMinConnections=dataSource[8]
        databaseconnTimeout=dataSource[9]
        databasereapTime=dataSource[10]
        databaseunusedTimeout=dataSource[11]
        databaseagedTimeout=dataSource[12]
    #Creare sursa de date
    dataSourceId = AdminJDBC.createDataSourceAtScope( scope, providerName, datasourceName, dsJNDIName, dataStoreHelperClassName, serverName, [['componentManagedAuthenticationAlias',compAuthAlias],['containerManagedPersistence','true'],['description',description]] )
    connectionPoolList = AdminConfig.list('ConnectionPool', dataSourceId)
    connectionPoolList = AdminUtilities.convertToList(connectionPoolList)
    connectionPoolId = connectionPoolList[0]
    AdminConfig.modify(connectionPoolId, [["maxConnections", databaseMaxConnections], ["minConnections", databaseMinConnections], ["connectionTimeout", databaseconnTimeout], ["reapTime", databasereapTime], ["unusedTimeout", databaseunusedTimeout], ["agedTimeout", databaseagedTimeout]])
    print 'Saving configuration...'
    AdminConfig.save()
    print "Configuration saved."

我的输入列表:

[datasourceName, JNDIName, AuthAlias, providerName, dataStoreHelperClassName, description, srvName,  maxConnections, minConnections, connTimeout, reapTime, unusedTimeout, agedTimeout]

我正在使用相同的脚本创建一个没有错误的Oracle数据源。我知道这两个进程之间的区别是serverName。对于DB2是ServerName,对于Oracle是URL。还有其他我不知道的区别吗?有人在我的代码中看到错误吗?

我的错误:

Exception: com.ibm.ws.scripting.ScriptingException com.ibm.ws.scripting.ScriptingException: com.ibm.ws.scripting.ScriptingException: WASX8018E: Cannot find a match for option value [databaseName, java.lang.String, TestSRV] for step configureResourceProperties 
WASX7017E: Exception received while running file "createDataSource.py"; exception information: com.ibm.ws.scripting.ScriptingException: WASX8018E: Cannot find a match for option value [databaseName, java.lang.String, TestSRV] for step configureResourceProperties

如果您需要更多信息,请留下评论。提前感谢!

2015年3月3日版

我在IBM的红皮书中找到了一些例子。

DB2数据库类型的脚本示例:

以下示例脚本包含字符串格式的可选属性:

AdminJDBC.createDataSourceAtScope("Cell=IBM-F4A849C57A0Cell01,Node=IBM-F4A849C57A0Node01,Server=server1", "MyTestJDBCProviderName", "newds2", "newds2/jndi", "com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper", "db1", " category=myCategory, componentManagedAuthenticationAlias=CellManager01/AuthDataAliase, containerManagedPersistence=true, description=’My description’, xaRecoveryAuthAlias=CellManager01/xaAliase", "serverName=localhost, driverType=4,portNumber=50000")

以下示例脚本包括列表格式的可选属性:

AdminJDBC.createDataSourceAtScope("Cell=IBM-F4A849C57A0Cell01,Node=IBM-F4A849C57A0Node01,Server=server1", "MyTestJDBCProviderName", "newds2", "newds2/jndi", "com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper", "db1", [[’category’, ’myCategory’], [’componentManagedAuthenticationAlias’, ’CellManager01/AuthDataAliase’], [’containerManagedPersistence’, ’true’], [’description’, ’My description’], [’xaRecoveryAuthAlias’, ’CellManager01/xaAliase’]] , [[’serverName’, ’localhost’], [’driverType’, 4], [’portNumber’, 50000]])

2015年4月16日版

我使用的是内置函数createDataSourceAtScope,还有另一个例子:

def createDataSourceAtScope( scope, JDBCName, datasourceName, jndiName, dataStoreHelperClassName, dbName, otherAttrsList=[], resourceAttrsList=[],  failonerror=AdminUtilities._BLANK_ ):

我必须调用上面的函数。有人看到问题了吗?:)

内置脚本位于:dmgrProfile/scriptLibraries/resources/JDBC/V70

我仍然不知道如何解决我的问题。如果有人有想法,请留言或回答。非常感谢!

我知道已经太晚了,但我在Docker上为Websphere解决了同样的问题。然后,我想分享我的解决方案。

调试ibmcom/websphere-traditional:8.5.5.18上的脚本的命令

/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh -conntype None -f exportConfig.py

Jython脚本


import os
import sys
newjdbc = AdminConfig.getid('/JDBCProvider:"DB2 Universal JDBC Driver Provider"/')
ds = AdminTask.createDatasource(newjdbc, '[-name NameDataSource -jndiName jdbc/NameDataSource -description "DB2 Universal Driver Datasource" -dataStoreHelperClassName com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper -containerManagedPersistence true -componentManagedAuthenticationAlias db2inst1 -configureResourceProperties [[databaseName java.lang.String SAMPLE][portNumber java.lang.Integer 50000][serverName java.lang.String 172.17.0.3]]]')
AdminConfig.create('MappingModule', ds, '[[authDataAlias db2inst1] [mappingConfigAlias "DefaultPrincipalMapping"]]')

AdminConfig.save()

最新更新