简体   繁体   中英

How do I connect to IBM Db2 Event Store from MATLAB?

是否可以从 MATLAB 连接到 IBM Db2 Event Store 实例?

IBM Db2 Event Store 2.0 supports the standard Db2 JDBC driver as it is integrated with the IBM Common SQL engine. Then to connect to MATLAB using the Database Explorer I just used the standard Db2 JDBC connection using the Db2 JDBC driver:

  1. Make sure you have the Database toolbox that provides the Database Explorer in MATLAB
  2. First go to the MATLAB editor and type: edit javaclasspath.txt in the Command Window, and in that file add the file path to the Db2 JDBC client driver downloaded from the IBM Data Server Client Packages page under the IBM Support website :
  • Eg /<path where the JDBC jar was placed>/db2jcc4.jar
  1. (AFTER UPDATING javaclasspath.txt restart MATLAB or look at this for reference )
  2. Go to the Apps tab in MATLAB app and select Database Explorer
  3. Select Configure Data Source and select "Configure JDBC Data Source" from the drop down menu
  4. Download the SSL keystore and password through the REST API using the instructions documented in the IBM Knowledge Center for Event Store , this is necessary because IBM Db2 Event Store is configured with SSL with aa default keystore out of the box (this may change if you configure it your own keystore after installation).
  5. In the JDBC Data Source Configuration Editor window do the following:
  • Enter any new name for the data source, eg EventStoreJDBC
  • Enter OTHER as the vendor
  • For Driver enter: com.ibm.db2.jcc.DB2Driver
  • In URL, add in the following: jdbc:db2://<Your Event Store Cluster VIP>:18729/EVENTDB:sslConnection=true;sslTrustStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStorePassword=<password for clientkeystore retrieved from cluster>;sslTrustStorePassword=<password for clientkeystore retrieved from cluster>;securityMechanism=15;pluginName=IBMIAMAuth;
  • Then click on any part of the window and the TEST button will pop up
  • Select TEST and you will be asked for a userid and password, where you can enter the eventstore userid and password for your system (eg admin and password )
  • Then you close the window.

Note these same instructions can be found in the IoT sample use case github repository for IBM Db2 Event Store

How do I do the same using the database object ?

This is what I tried

conn = database('db2inst1','admin','password','com.ibm.db2.jcc.DB2Driver','jdbc:db2://<Your Event Store Cluster VIP>:18729/EVENTDB:sslConnection=true;sslTrustStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStorePassword=<password for clientkeystore retrieved from cluster>;sslTrustStorePassword=<password for clientkeystore retrieved from cluster>;securityMechanism=15;pluginName=IBMIAMAuth;');

This is what I see

>> conn = database('db2inst1','admin','password','com.ibm.db2.jcc.DB2Driver','jdbc:db2://9.30.192.111:18729/EVENTDB:sslConnection=true;sslTrustStoreLocation=/Users/cmgarcia/Documents/MATLAB/eventstore/clientkeystore;sslKeyStoreLocation=/Users/cmgarcia/Documents/MATLAB/eventstore/clientkeystore;sslKeyStorePassword=Cc2cZ8TxdhWf;sslTrustStorePassword=Cc2cZ8TxdhWf;securityMechanism=15;pluginName=IBMIAMAuth;')

conn = 

  connection with properties:

                  DataSource: 'db2inst1'
                    UserName: 'admin'
                      Driver: 'com.ibm.db2.jcc.DB2Driver'
                         URL: 'jdbc:db2://9.30.192.111:1 ...'
                     Message: ''
                        Type: 'JDBC Connection Object'
  Database Properties:

                  AutoCommit: 'on'
                    ReadOnly: 'off'
                LoginTimeout: 0
      MaxDatabaseConnections: 0

  Catalog and Schema Information:

              DefaultCatalog: ''
                    Catalogs: {''}
                     Schemas: {'ADMIN', 'NULLID', 'NULLIDR1' ... and 12 more}

  Database and Driver Information:

         DatabaseProductName: 'DB2/LINUXX8664'
      DatabaseProductVersion: 'SQL110190'
                  DriverName: 'IBM Data Server Driver fo ...'
               DriverVersion: '4.26.14'

>> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM