Ask Your Question

Query failed due to type mismatch STRING for column id

asked 2018-10-19 03:55:21 -0500

harley gravatar image

updated 2018-10-19 04:07:09 -0500

when doing a replication data from mysql to mysql, I got the question in stage JDBC Producer as follows:

2018-10-19 16:20:20,896 INFO JavaScriptProcessor - Record value is: {TABLE_NAME=test, SQL_TYPE=INSERT, a=aaa, id=31} 2018-10-19 16:20:20,902 ERROR JdbcBaseRecordWriter - Query failed due to type mismatch STRING for column id

In the Field to Column Mapping ,the Parameterized Value of "id" is "CAST (? AS INTEGER)" , DATA TYPE is INTEGER,SDC Field is "/id" and the type of column id in mysql is INT. I have tested to change the Parameterized Value of "id" to "?" and make DATA TYPE to "use db column type" or "INTEGER",but they didn`t work ,The log I intercepted is shown below:

errorStackTrace:JDBC_23 - Can't coerce '34' of type 'STRING' to column 'id',...., "value":"[{"type":"STRING","value":"test","sqpath":"/TABLE_NAME","dqpath":"/TABLE_NAME"},{"type":"STRING","value":"INSERT","sqpath":"/SQL_TYPE","dqpath":"/SQL_TYPE"},{"type":"STRING","value":"aaa","sqpath":"/a","dqpath":"/a"},{"type":"STRING","value":"31","sqpath":"/id","dqpath":"/id"}]". so how could I resolve the questions?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-10-20 04:45:44 -0500

harley gravatar image

updated 2018-10-20 04:49:29 -0500

After an afternoon of trying ,I have solved the question,thanks for Mr. Pat Patterson`s advice, I use the processors of Field Type Converter have successfully changed the data type.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-10-19 03:55:21 -0500

Seen: 389 times

Last updated: Oct 20 '18