用于连接Couchbase的IBM Mobilefirst Java Adapter

时间:2017-05-03 18:17:38

标签: ibm-mobilefirst couchbase mobilefirst-adapters

我们可以通过Mobilefirst 8 Java或Javascript SQL适配器连接到Couchbase DB吗?如果可行,请提供其他选择。

2 个答案:

答案 0 :(得分:3)

您可以使用MFP 8.0 Java适配器或Javascript HTTP适配器,并使用它来对Couchbase DB进行REST调用。

答案 1 :(得分:1)

是的,可以使用MFP 8.0 JavaScript或Java HTTP Adapters连接任何NoSQL DB(Couchbase DB),并使用REST调用。

以下是使用MFP 8.0 JavaScript HTTP Adapter连接到IBM Cloudant NoSQL DB的示例示例。

AdapterSample.js file -->

              function getDocByKey(key) {
              var path = '/my_database/'+key;
              var input = {
                   method : 'get',
                   returnedContentType :'json',
                   path : path
              };

              return WL.Server.invokeHttp(input);   

              }

adapter.xml file -->


<mfp:adapter name="AdapterSample"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:mfp="http://www.ibm.com/mfp/integration"
             xmlns:http="http://www.ibm.com/mfp/integration/http">

    <displayName>AdapterSample</displayName>
    <description>AdapterSample</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>https</protocol>
            <domain> <-- DB URL here--> </domain>
            <port>443</port>
            <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
            <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
            <authentication>
                <basic/>
                <serverIdentity>
                    <username> <--DB Username here--> </username>
                    <password> <--DB Password here--> </password>
                </serverIdentity>
            </authentication>
            <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>

        </connectionPolicy>
    </connectivity>

    <procedure name="getDocByKey" secured="false"/>


</mfp:adapter>

点击此处了解更多信息https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/adapters/