otter版本:4.2.11 mysql版本:5.6.35-log --------------执行建表语句如下:
CREATE TABLE test ( id bigint(20) NOT NULL AUTO_INCREMENT, trade_tx_id bigint(20) NOT NULL COMMENT '交易唯一编码', oper_type tinyint(1) DEFAULT NULL COMMENT '订单类型1 买方, 2 卖方;3--系统运营人员', oper_pin varchar(32) DEFAULT NULL COMMENT '操作用户', buyer_pin varchar(32) DEFAULT NULL COMMENT '买方账户号(目前手机号)', seller_pin varchar(32) DEFAULT NULL COMMENT '卖方账户号(目前手机号)', buy_comp_name varchar(128) DEFAULT NULL COMMENT '买家公司名称', sell_comp_name varchar(128) DEFAULT NULL COMMENT '卖家公司名称', buy_comp_id varchar(32) DEFAULT NULL COMMENT '买方公司id', sell_comp_id varchar(32) DEFAULT NULL COMMENT '卖家公司id', role_type tinyint(2) DEFAULT NULL COMMENT '用户角色:0 老板; 1 出纳; 2 交易员', source tinyint(1) DEFAULT NULL COMMENT '订单来源: 1:Pc;2:手机;3:ipad;4:wap; 5:其他', cancel_weight decimal(15,3) DEFAULT '0.000' COMMENT '违约重量', buy_pay_amount decimal(15,2) DEFAULT '0.00' COMMENT '买方违约金', sell_pay_amount decimal(15,2) DEFAULT '0.00' COMMENT '卖方违约金', status int(8) DEFAULT NULL COMMENT '状态', status_desc varchar(64) DEFAULT NULL COMMENT '状态描述', create_time timestamp NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间', update_time timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, order_no varchar(16) DEFAULT NULL COMMENT '撤销的订单号', warehouse_code varchar(16) DEFAULT NULL COMMENT '仓库编号', owner_code varchar(16) DEFAULT NULL COMMENT '货主编号', receipt_no varchar(16) DEFAULT NULL COMMENT '卖家挂单仓单号', buy_owner_code varchar(16) DEFAULT NULL COMMENT '买家货主编号', buy_receipt_no varchar(16) DEFAULT NULL COMMENT '买家虚拟仓单号', trade_type varchar(16) DEFAULT NULL COMMENT '交易类型 (连续交易2,普通交易1)', orig_order_no varchar(16) DEFAULT NULL COMMENT '违约发起的订单号', orig_receipt_no varchar(16) DEFAULT NULL COMMENT '违约发起的仓单号', orig_owner_code varchar(16) DEFAULT NULL COMMENT '违约发起的货主编号', PRIMARY KEY (id), UNIQUE KEY index_trade_tx_id (trade_tx_id) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='违约单信息';
-------------抛出错误如下: pid:13 nid:1 exception:setl:com.alibaba.otter.node.etl.load.exception.LoadException: java.util.concurrent.ExecutionException: com.alibaba.otter.node.etl.load.exception.LoadException: com.alibaba.otter.node.etl.load.exception.LoadException: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is 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 'order' at line 1 Caused by: java.util.concurrent.ExecutionException: com.alibaba.otter.node.etl.load.exception.LoadException: com.alibaba.otter.node.etl.load.exception.LoadException: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is 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 'order' at line 1 at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at com.alibaba.otter.node.etl.load.loader.db.DataBatchLoader.load(DataBatchLoader.java:107) at com.alibaba.otter.node.etl.load.loader.OtterLoaderFactory.load(OtterLoaderFactory.java:50) at com.alibaba.otter.node.etl.load.LoadTask$1.run(LoadTask.java:85) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: com.alibaba.otter.node.etl.load.exception.LoadException: com.alibaba.otter.node.etl.load.exception.LoadException: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is 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 'order' at line 1 Caused by: com.alibaba.otter.node.etl.load.exception.LoadException: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is 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 'order' at line 1 Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar []; nested exception is 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 'order' at line 1 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction.doDdl(DbLoadAction.java:357) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction.load(DbLoadAction.java:135) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction$$FastClassByCGLIB$$d932a4cb.invoke() at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:618) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction$$EnhancerByCGLIB$$80fd23c2.load() at com.alibaba.otter.node.etl.load.loader.db.DataBatchLoader$2.call(DataBatchLoader.java:198) at com.alibaba.otter.node.etl.load.loader.db.DataBatchLoader$2.call(DataBatchLoader.java:189) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: 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 'order' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) at com.mysql.jdbc.Util.getInstance(Util.java:384) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2690) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:783) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:626) at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264) at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction$1.doInStatement(DbLoadAction.java:363) at com.alibaba.otter.node.etl.load.loader.db.DbLoadAction$1.doInStatement(DbLoadAction.java:357) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396) ... 14 more
原提问者GitHub用户 wangzisong21
由于数据库名称使用了关键字order,otter有段代码result &= stmt.execute("use " + data.getDdlSchemaName());--这个是otter load模块ddl的处理,默认会加use schema。关键字需要加上符号
解决办法,修改数据库名称为非关键字,修改otter代码,拼接字符串
原回答者GitHub用户wangzisong21
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。