0

我对输出语法错误的 DBreport 调解器有疑问,但我在 SQL 语句中看不到任何错误

<sequence xmlns="http://ws.apache.org/ns/synapse" name="_dbcount">
   <dblookup>
      <connection>
         <pool>
            <password>1234</password>
            <user>root</user>
            <url>jdbc:mysql://localhost:3306/new_db</url>
            <driver>com.mysql.jdbc.Driver</driver>
         </pool>
      </connection>
      <statement>
         <sql>
            <![CDATA[            select * from consume where username= ? and id_api+ ?]]></sql>
            <parameter value="riccardo" type="VARCHAR" />
            <parameter value="1" type="INTEGER" />
            <result name="result_use" column="use" />
            <result name="result_user" column="username" />
         </statement>
      </dblookup>
      <dbreport>
         <connection>
            <pool>
               <password>1234</password>
               <user>root</user>
               <url>jdbc:mysql://localhost:3306/new_db</url>
               <driver>com.mysql.jdbc.Driver</driver>
               <property name="autocommit" value="false" />
            </pool>
         </connection>
         <statement>
            <sql>
               <![CDATA[UPDATE consume SET use=21 WHERE username='riccardo' AND id_api='1']]></sql>
            </statement>
         </dbreport>
         <log level="custom">
            <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="result for client" expression="get-property('result_user')" />
            <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="result for use" expression="get-property('result_use')" />
         </log>
      </sequence>

第一个 DB 查找工作正常,但 DBreport 中的第二个 SQL 语句无法更新值:

ERROR - DBReportMediator Error execuring insert statem
ent : UPDATE consume SET use='21' WHERE username='riccardo' AND id_api='1' again
st DataSource : jdbc:mysql://localhost:3306/new_db
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'use='21' WHERE username='riccardo' AND id_api=
'1'' at line 1
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)...

我的表格如下:

消费(int id,varchar 用户名,int id_api,int 使用)用户(int id,varchar 用户名,varchar 密码)

非常感谢

编辑我认为在 Mysql DB 上写入时 DBREPORT 和 DBLOOKUP 中介存在重大问题,阅读很好,但更新和插入不起作用......告诉我我是否错了

4

1 回答 1

0

努维奥,

我认为这个问题的出现不是因为 DBReport 调解器有问题。在查看报告的堆栈跟踪和序列配置时,我可以看到您已将“使用”定义为列名。我不太确定您是如何使用“use”一词创建数据库列的,因为它是 MySQL 关键字,并且只要您的 SQL 查询中有关键字作为列或任何其他用户定义的属性,MySQL 查询编译器就会抛出 SQLException . 使用非关键字名称代替“使用”列将解决您的问题。

干杯,普拉巴斯

于 2012-09-07T17:37:25.777 回答