1

I want to pass my query to database for retrieving the column. I am passing dynamic columns using ESB my configuration is like this

 <proxy xmlns="http://ws.apache.org/ns/synapse" name="dbl3" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">   <target>
         <inSequence>
            <property name="A" value="select e_name,e_address from emp where " scope="default" type="STRING"/>
            <property name="B" expression="//fieldname/text()" scope="default" type="STRING"/>
            <property name="C" expression="//fieldvalue/text()" scope="default" type="STRING"/>
            <property name="D" value="=" scope="default" type="STRING"/>
            <property name="E" expression="concat(get-property('A'),get-property('B'),get-property('D'),get-property('C'))" scope="default" type="STRING"/>
            <dblookup>
               <connection>
                  <pool>
                     <password>Youtility11</password>
                     <user>youtilitydba</user>
                     <url>jdbc:postgresql://localhost:5432/sample</url>
                     <driver>org.postgresql.Driver</driver>
                  </pool>
               </connection>
               <statement>
                  <sql>get-property('E')</sql>
                  <result name="ee" column="e_name"/>
               </statement>
            </dblookup>
            <log level="custom">
               <property name="AA" expression="get-property('A')"/>
               <property name="BB" expression="get-property('B')"/>
               <property name="CC" expression="get-property('C')"/>
               <property name="DD" expression="get-property('ee')"/>
               <property name="EE" expression="get-property('E')"/>
            </log>
         </inSequence>
         <outSequence>
                <send/>
             </outSequence>   </target>   <description></description> </proxy>

My output like this:

EE = select e_name,e_address from emp where e_address=thane
EE = select e_name,e_address from emp where e_no=5

Based on input values query will generate, how can I pass the above query to the database? My error is like this:

[2013-01-24 14:22:32,743] ERROR - DBLookupMediator Error executing statement : get-property('E') against DataSource : jdbc:postgresql://localhost:5432/sample
org.postgresql.util.PSQLException: ERROR: syntax error at or near "get"
 Position: 1
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at org.apache.synapse.mediators.db.DBLookupMediator.processStatement(DBLookupMediator.java:46)
    at org.apache.synapse.mediators.db.AbstractDBMediator.mediate(AbstractDBMediator.java:143)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:154)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
    at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:144)
    at org.apache.axis2.transport.http.util.RESTUtil.processXMLRequest(RESTUtil.java:89)
    at org.apache.synapse.transport.nhttp.util.RESTUtil.processPOSTRequest(RESTUtil.java:189)
    at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:411)
    at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:268)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
4

1 回答 1

2

恐怕您无法<sql/>使用“get-property”构造将 SQL 语句传递给 DBLookup/DBReport 中介的“”元素。此外,我相信您正在尝试做的是将变量传递给 SQL 查询的一种技巧。执行此操作的正确方法应该是使用 WSO2 数据服务服务器。请参阅 WSO2 DSS [1] 的文档,该文档为您提供了有关如何使用它来实现数据操作任务的综合指南,并为用户提供了丰富的功能集。

[1] http://docs.wso2.org/wiki/display/DSS301/WSO2+Data+Services+Server+Documentation

于 2013-02-23T18:08:55.590 回答