Record an error when phoenix inserts data
The error message is as follows
Caused by: org.apache.phoenix.exception.PhoenixParserException: ERROR 602 (42P00): Syntax error. Missing "EOF" at line 5, column 10.
at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)
at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:111)
at org.apache.phoenix.jdbc.PhoenixStatement$PhoenixStatementParser.parseStatement(PhoenixStatement.java:1644)
at org.apache.phoenix.jdbc.PhoenixStatement.parseStatement(PhoenixStatement.java:1727)
at org.apache.phoenix.jdbc.PhoenixPreparedStatement.<init>(PhoenixPreparedStatement.java:94)
at org.apache.phoenix.jdbc.PhoenixConnection.prepareStatement(PhoenixConnection.java:896)
at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:331)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:87)
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
... 9 more
Caused by: MissingTokenException(inserted [@-1,0:0='<missing EOF>',<-1>,5:9] at ,)
at org.apache.phoenix.parse.PhoenixSQLParser.recoverFromMismatchedToken(PhoenixSQLParser.java:374)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:534)
at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)
... 31 more
The content of mapper is as follows
<select id="insert" parameterType="MeasureInitialEntity">
upsert into ${tableName} (measureDocNo, clientNo, pointNo, valueK, TValue, measureDate, createDate) values
(#{data.measureDocNo}, #{data.clientNo}, #{data.pointNo}, #{data.valueK}, #{data.TValue}, #{data.measureDate}, #{data.createDate})
</select>
<select id="insertByList" resultType="MeasureInitialEntity" parameterType="java.util.Map">
upsert into ${tableName} (measureDocNo, clientNo, pointNo, valueK, TValue, measureDate, createDate) values
<foreach collection="dataList" item="data" index="index" separator=",">
(#{data.measureDocNo}, #{data.clientNo}, #{data.pointNo}, #{data.valueK}, #{data.TValue}, #{data.measureDate}, #{data.createDate})
</foreach>
</select>
At the beginning, I used batch insert to report an error. I stopped and checked, but I couldn’t see any problems. After inserting a piece of data, it worked, and then I switched
to batch insert, but it didn’t work .
The same error is still reported.
It seems that only the batch submission method may be different.
Then it was changed to manual submission. Only then did I find that the original phoenix+mybatis sql statement only has a single submission. After the values The second parameter will report an error...
After searching a lot of information, I found that phoenix+mybatis does not have batch insert statements, only single insert...