Worklight 6.2中的DB2 SQL语句(SQL适配器)

时间:2014-08-17 11:48:33

标签: sql db2 ibm-mobilefirst worklight-adapters

我要求求助,我在工作中相对较新,我必须开发一个与DB2数据库通信的程序。 我正在使用Worklight 6.2和DB2 express-c 10.5.1,我希望得到这个标准的结果:

var procedure1Statement = WL.Server.createSQLStatement("SELECT location FROM ORG;");
function procedure1(param) {
    return WL.Server.invokeSQLStatement({
        preparedStatement : procedure1Statement,
        parameters : [param]
    });
}

设置我的SQL适配器:

<wl:adapter name="DB2Adapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:sql="http://www.worklight.com/integration/sql">

    <displayName>DB2Adapter</displayName>
    <description>DB2Adapter</description>
    <connectivity>
        <connectionPolicy xsi:type="sql:SQLConnectionPolicy">
        <dataSourceDefinition>
            <driverClass>com.ibm.db2.jcc.DB2Driver</driverClass>
            <url>jdbc:db2://localhost:50000/sample</url>
            <user>Ondra</user>
            <password>OndraPass</password>  
            </dataSourceDefinition>
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="5" />
    </connectivity>
    <procedure name="procedure1"/>
    <procedure name="login" securityTest="LDAPAdapter-securityTest"/>

</wl:adapter>

我已将.jar文件复制到服务器lib文件夹(db2cc_license_cu.jar,db2cc.jar)

如果我尝试通过eclipse一个receve语句来调用worklight过程:

{
   "errors": [
      "Runtime: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;CT location FROM ORG;END-OF-STATEMENT, DRIVER=3.66.46.\nPerformed query:\nSELECT location FROM ORG;"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

在eclipse控制台中是:

{[AUDIT   ] CWWKG0016I: Starting server configuration update.
[AUDIT   ] CWWKG0018I: The server configuration was not updated. No functional changes were detected.
[ERROR   ] FWLSE0099E: An error occurred while invoking procedure  [project DataPower]DB2Adapter/SqlStatementFWLSE0100E:  parameters: [project DataPower]
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;CT location FROM ORG;END-OF-STATEMENT, DRIVER=3.66.46.
Performed query:
SELECT location FROM ORG;
FWLSE0101E: Caused by:  [project DataPower]com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;CT location FROM ORG;END-OF-STATEMENT, DRIVER=3.66.46java.lang.RuntimeException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;CT location FROM ORG;END-OF-STATEMENT, DRIVER=3.66.46.
Performed query:
SELECT location FROM ORG;
    at com.worklight.adapters.sql.SQLQuery.invoke(SQLQuery.java:94)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at com.worklight.integration.model.InvocationContext$DirectExecutorService.execute(InvocationContext.java:284)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at com.worklight.integration.model.InvocationContext.submit(InvocationContext.java:138)
    at com.worklight.integration.model.InvocationContextManager.submitInvocation(InvocationContextManager.java:58)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.callProcedure(DataAccessServiceImpl.java:516)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.access$100(DataAccessServiceImpl.java:60)
    at com.worklight.integration.services.impl.DataAccessServiceImpl$3.execute(DataAccessServiceImpl.java:411)
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:408)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:475)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:451)
    at com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation.invokeDynamicProcedure(JavaScriptIntegrationLibraryImplementation.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at org.mozilla.javascript.gen._integration_js_1._c_anonymous_19(/integration.js:226)
    at org.mozilla.javascript.gen._integration_js_1.call(/integration.js)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.DB2Adapter_impl_js_8._c_procedure1_1(DB2Adapter-impl.js:11)
    at org.mozilla.javascript.gen.DB2Adapter_impl_js_8.call(DB2Adapter-impl.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at org.mozilla.javascript.gen.DB2Adapter_impl_js_8.call(DB2Adapter-impl.js)
    at com.worklight.integration.js.JavaScriptManager.callFunction(JavaScriptManager.java:240)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:214)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:194)
    at com.worklight.integration.services.impl.AdapterManagerImpl.invokeFunction(AdapterManagerImpl.java:117)
    at com.worklight.integration.js.JavaScriptProcedureInvoker.invoke(JavaScriptProcedureInvoker.java:42)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at com.worklight.server.util.ProjectLocal$1RunnableWrapper.run(ProjectLocal.java:261)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;CT location FROM ORG;END-OF-STATEMENT, DRIVER=3.66.46
    at com.ibm.db2.jcc.am.dd.a(dd.java:741)
    at com.ibm.db2.jcc.am.dd.a(dd.java:60)
    at com.ibm.db2.jcc.am.dd.a(dd.java:127)
    at com.ibm.db2.jcc.am.oo.c(oo.java:2763)
    at com.ibm.db2.jcc.am.oo.d(oo.java:2751)
    at com.ibm.db2.jcc.am.oo.a(oo.java:2200)
    at com.ibm.db2.jcc.am.po.a(po.java:7379)
    at com.ibm.db2.jcc.t4.ab.h(ab.java:141)
    at com.ibm.db2.jcc.t4.ab.b(ab.java:41)
    at com.ibm.db2.jcc.t4.o.a(o.java:32)
    at com.ibm.db2.jcc.t4.tb.i(tb.java:145)
    at com.ibm.db2.jcc.am.oo.ib(oo.java:2169)
    at com.ibm.db2.jcc.am.po.tc(po.java:3547)
    at com.ibm.db2.jcc.am.po.b(po.java:4345)
    at com.ibm.db2.jcc.am.po.jc(po.java:2744)
    at com.ibm.db2.jcc.am.po.execute(po.java:2724)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
    at com.worklight.adapters.sql.SQLQuery.invoke(SQLQuery.java:80)
    ... 46 more

                                                                                                               com.worklight.common.log.filters.ErrorFilter}

有人可以帮我吗?我有点迷失

1 个答案:

答案 0 :(得分:0)

解决方案是删除';'在SQL语句中而不是在IBM教程中