【问题标题】:Create DataSource for DB2 Provider using wsadmin (Websphere Application Server 8.5)使用 wsadmin (Websphere Application Server 8.5) 为 DB2 Provider 创建 DataSource
【发布时间】:2015-04-19 04:48:24
【问题描述】:

我有一个脚本,它使用 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 数据源。我知道这些进程之间的区别是服务器名称。 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

如果您需要更多信息,请发表评论。提前致谢!

编辑 03.03.2015

我在 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]])

编辑 16.04.2015

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

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

我必须像上面那样调用函数。有没有人看到问题? :)

内置脚本在:dmgrProfile/scriptLibraries/resources/JDBC/V70

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

【问题讨论】:

  • 有谁知道如何解决这个问题?谢谢!
  • 有什么想法吗?我没有解决办法。 :(提前谢谢!
  • 有同样的问题 - 我正在使用 AdminJDBC 的 createDataSourceAtScope。你能分享一下你是如何解决这个问题的吗?
  • 嗨!我当时没有解决问题。我想我找到了一些解决方法。我不记得了。我会搜索那些脚本并回答。
  • 谢谢。我也最终扩展了脚本并让它工作。看起来脚本有问题,因为非 jt400 正在工作。

标签: db2 websphere datasource jython wsadmin


【解决方案1】:

我知道为时已晚,但我为 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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-19
    • 2012-07-25
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    相关资源
    最近更新 更多