DatabaseRoute 和 DatabaseRetrieve 节点通过使用存储在 Integration 节点注册表中的连接详细信息构建自己的 JDBC 连接,其中包含标准 DBMS JDBC 提供者设置。 如果您正使用 DB2 通用数据库,请使用以下指示信息创建 JDBC 提供者条目。
您可以使用 mqsicreateconfigurableservice 命令(该命令在以下脚本中提供)创建名为 SIMPLERROUTEDB 的新 JDBC 提供者条目。此条目由样本所使用的数据库节点中的“数据源名称”属性字段引用。以下指示信息还可配置具有用户标识和密码的 JDBC 提供者条目以供 Integration 节点在访问数据库时使用。
为数据库创建 JDBC 提供者条目:
mqsistart IB9NODE
mqsideleteconfigurableservice IB9NODE -c JDBCProviders -o SIMPLERROUTEDB mqsicreateconfigurableservice IB9NODE -c JDBCProviders -o SIMPLERROUTEDB -n connectionUrlFormat,databaseName,description,jarsURL,portNumber,serverName, type4DatasourceClassName,type4DriverClassName -v "jdbc:db2://[serverName]:[portNumber]/[databaseName]:user=[user];password=[password];, SROUTEDB,Simplified Database Routing Sample Database,<JARS URL>,<PORT NUMBER>, <SERVER NAME>,com.ibm.db2.jcc.DB2DataSource,com.ibm.db2.jcc.DB2Driver"注意:以上脚本仅包含两个命令,每个命令都必须在其自己的单独行上开始和结束。因此,复制并粘贴脚本时,整个脚本必须仅占用两行,如下所示:
mqsideleteconfigurableservice IB9NODE -c JDBCProviders -o SIMPLERROUTEDB
mqsicreateconfigurableservice IB9NODE -c JDBCProviders -o SIMPLERROUTEDB -n connectionUrlFormat,databaseName,description,jarsURL,portNumber,serverName,type4DatasourceClassName,type4DriverClassName -v "jdbc:db2://[serverName]:[portNumber]/[databaseName]:user=[user];password=[password];,SROUTEDB,Simplified Database Routing Sample Database,<JARS URL>,<PORT NUMBER>,<SERVER NAME>,com.ibm.db2.jcc.DB2DataSource,com.ibm.db2.jcc.DB2Driver"如果未复制脚本并将其粘贴为两行,那么尝试运行该脚本将产生类似“-n 未被识别为有效程序....”的错误。 这是因为,系统错误地识别每个新行作为新命令的起始行。
simplifieddbrouting.bat
运行脚本时,它将执行以下任务:
BIP8984W: Configurable service object name 'JDBCProviders : SIMPLERROUTEDB' was not found. The user has tried to delete or modify a configurable service object name that does not exist. Check the names of the existing configurable services using the mqsireportproperties command. Then modify the external resource object name and reissue the command. BIP2087E: Broker IB9NODE was unable to process the internal configuration message. The entire internal configuration message failed to be processed successfully. The internal configuration message failed to be processed, use the messages following this message to determine the reasons for the failure. BIP8036E: Negative response received. This command sends an internal configuration message to the broker, the response received indicated that the internal configuration message was unsuccessful. Check that the WebSphere MQ transport is available. Check the system log for further information.请忽略此消息。显示此消息是因为脚本尝试先删除名为 SIMPLERROUTEDB 的现有 JDBCProvider 注册表条目,然后再重新创建该条目。如果之前未曾运行此脚本,那么将无法在注册表中找到该条目。
mqsireportproperties IB9NODE -o SIMPLERROUTEDB -c JDBCProviders -r
如果已成功更新,那么从该命令报告的属性输出将与以下示例匹配:
JDBCProviders
SIMPLERROUTEDB
connectionUrlFormat='jdbc:db2://[serverName]:[portNumber]/[databaseName]:user=[user];password=[password];'
connectionUrlFormatAttr1=''
connectionUrlFormatAttr2=''
connectionUrlFormatAttr3=''
connectionUrlFormatAttr4=''
connectionUrlFormatAttr5=''
databaseName='SROUTEDB'
databaseType='default_Database_Type'
databaseVersion='default_Database_Version'
description='Simplified Database Routing Sample Database'
environmentParms='default_none'
jarsURL='C:\Program Files\IBM\SQLLIB\java'
portNumber='50000'
securityIdentity='default_User@default_Server'
serverName='localhost'
type4DatasourceClassName='com.ibm.db2.jcc.DB2DataSource'
type4DriverClassName='com.ibm.db2.jcc.DB2Driver'
BIP8071I: Successful command completion. 要指定用户标识和密码以与 JDBC 提供者 SIMPLERROUTEDB 相关联,请使用 mqsisetdbparms 和 mqsichangeproperties 命令。此用户标识必须是您创建数据库时所使用的同一用户标识。
mqsisetdbparms IB9NODE -n jdbc::mySecurityIdentity -u <user ID> -p <password>
mqsichangeproperties IB9NODE -c JDBCProviders -o SIMPLERROUTEDB -n securityIdentity -v mySecurityIdentity
有关更多信息,请参阅 IBM Integration Bus 文档中的启动到数据库的 JDBC 连接和 DatabaseRoute 节点的“使 JDBC 提供者服务对 DatabaseRoute 节点可用”部分。