简体   繁体   English

WSO2 MySQL适配器语法错误

[英]WSO2 MySQL Adaptor Sytax Error

I am trying to create an event formatter for MySql in WSO2 but am hitting a problem. 我正在尝试在WSO2中为MySql创建事件格式化程序,但遇到了问题。 It appears to be linked to the use of "Composite Key Columns". 它似乎与“复合键列”的使用有关。 The error I am getting is: 我得到的错误是:

ERROR - {MysqlEventAdaptorType} 错误-{MysqlEventAdaptorType}
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Window = '15'' at line 1 检查与您的MySQL服务器版本相对应的手册,以在第1行的'Window ='15'附近使用正确的语法

This only happens if I use a two or more keys in the formatter: 仅当我在格式化程序中使用两个或多个键时,才会发生这种情况:

<eventFormatter name="GenericAccountSQLFormatter" statistics="enable"
  trace="enable" xmlns="http://wso2.org/carbon/eventformatter">
  <from streamName="GenericAccountMeasureStream" version="1.0.0"/>
  <mapping customMapping="disable" type="map"/>
  <to eventAdaptorName="APCSQLOut" eventAdaptorType="mysql">
    <property name="table.name">AccountStats</property>
    <property name="update.keys">AccountId,Window</property>
    <property name="execution.mode">insert-or-update</property>
  </to>
</eventFormatter>

Removing either of the keys (AccountId, Window) then the formatter will send data to MySQL. 删除其中一个键(AccountId,Window),然后格式化程序会将数据发送到MySQL。

Can anyone help? 有人可以帮忙吗?

This is a bug and happens when existing events are sent to a MySQL adaptor with composite keys. 这是一个错误,当现有事件通过组合键发送到MySQL适配器时会发生。 Created a jira to track this and the source patch is also available there. 创建了一个jira来跟踪此问题,并且在那里也提供了源补丁。

If you don't want to create/apply a patch, then as a quick workaround for now - you can output a composite key from CEP query by concatenating the two attributes and use that as the key in formatter. 如果您不想创建/应用补丁程序,那么作为一种快速的解决方法-您可以通过连接两个属性并将其用作格式化程序中的密钥,从CEP查询中输出复合密钥。

UPDATE UPDATE

The source patch with the fix and build instructions are now available in the jira here . 现在,可以在此处jira中获得带有修复和构建说明的源补丁。 Once built, you need to apply it as a patch to CEP. 构建完成后,您需要将其作为补丁应用到CEP。 To apply it as a patch, create a directory named patch0xyz ( xyz are digits as in patch0135, also make xyz > 100) in <CEP>/repository/components/patches and then place the jar inside it. 要将其应用为补丁,请在<CEP>/repository/components/patches创建一个名为patch0xyz的目录(xyz是patch0135中的数字,也使xyz> 100),然后将jar放入其中。 Then you need to rename the jar as org.wso2.carbon.event.output.adaptor.mysql_1.0.1.jar . 然后,您需要将罐子重命名为org.wso2.carbon.event.output.adaptor.mysql_1.0.1.jar Then restart the server. 然后重新启动服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM