Ask Your Question

How to insert a boolean type false/true from SQL Server into bit type of MySQL with JDBC Producer

asked 2018-08-16 04:08:09 -0500

Dean Han gravatar image

updated 2018-08-16 16:24:26 -0500

metadaddy gravatar image

Hi , I am using a JDBC multitble to fetch data from SQLserver, then insert these records into the Mysql DB with same table structures, but when doing boolean type data, I got below error:

JDBC_23 - Can't coerce 'false' of type 'BOOLEAN' to column 'xxxxx'

Anyone can help me? Thank you!


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-16 10:55:23 -0500

metadaddy gravatar image

The problem is that, technically, a BOOLEAN field is not a numeric type, but a BIT column in MySQL is. You can use Expression Evaluator to turn the BOOLEAN into an integer, and it will work. Just set your output field /xxxxx to an expression like:

${record:value('/xxxxx') ? 1 : 0}

For example:

image description

image description

mysql> select name, bin(value) from bit_table;
| name | bin(value) |
| Jim  | 1          |
| Bob  | 0          |
2 rows in set (0.00 sec)
edit flag offensive delete link more


Thanks a lot, it is working. I figure out a way with Field replacer and field type converter, but apparently, the solution you provided is easier and better. Thanks again.

Dean Han gravatar imageDean Han ( 2018-08-17 03:51:42 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-16 04:08:09 -0500

Seen: 3,492 times

Last updated: Aug 16 '18