0
votes

I ned to ask for help, I am relatively new in worklight and I have to develop a program which comunicate with DB2 database. I am working with Worklight 6.2 and DB2 express-c 10.5.1 and i want to get result for this stanement:

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

setting of my SQL adapter:

<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>

I have copied .jar files to server lib folder (db2cc_license_cu.jar, db2cc.jar)

If I try to Invoke worklight procedure by eclipse a receve statement:

{
   "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": [
   ]
}

and in eclipse console is that:

{[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}

Could anyone help me please? I am little bit lost

1
Try to remove the ; from your SQL string.a_horse_with_no_name
You are right :-D I do not know why I did not try that, but in tutorials pdf of IBm there is the ';'. Thank you very mutchOBorovec

1 Answers

0
votes

The solution is removing the ';' in SQL statement insted of that it is in IBM tutorials