From 8cadd585c6af6f22036393614c66e6c45f80ddee Mon Sep 17 00:00:00 2001 From: jiucheng Date: Wed, 20 Feb 2019 09:49:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?adapter=20rdb=E6=97=A0=E6=B3=95=E5=90=8C?= =?UTF-8?q?=E6=AD=A5ddl=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20adapter/support/MessageUtil.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alibaba/otter/canal/client/adapter/support/MessageUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java index 93ca987b..51e6a1b4 100644 --- a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java +++ b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/MessageUtil.java @@ -37,6 +37,7 @@ public class MessageUtil { CanalEntry.EventType eventType = rowChange.getEventType(); final Dml dml = new Dml(); + dml.setIsDdl(rowChange.getIsDdl()); dml.setDestination(destination); dml.setGroupId(groupId); dml.setDatabase(entry.getHeader().getSchemaName()); From f7e490f7a01f48fac31df22ff5f0b45780516467 Mon Sep 17 00:00:00 2001 From: jiucheng Date: Wed, 20 Feb 2019 10:10:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81adapter/rdb=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?=E5=BA=93=E8=A1=A8=E5=AD=97=E6=AE=B5(varchar,char,text,longtext?= =?UTF-8?q?)=E9=9D=9E=E7=A9=BA=E7=BA=A6=E6=9D=9F=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=202=E3=80=81=E4=B8=BB=E5=BA=93=E5=AD=98=E5=9C=A80000-?= =?UTF-8?q?00-00=2000:00:00=E6=97=B6=E9=97=B4=E6=97=B6=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?=E5=BA=93=E8=A1=A8=E5=AD=97=E6=AE=B5=E6=98=AF=E9=9D=9E=E7=A9=BA?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F=E6=97=B6=EF=BC=8C=E6=97=A0=E6=B3=95=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=97=AE=E9=A2=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/adapter/support/JdbcTypeUtil.java | 16 +++++++++------- .../client/adapter/rdb/support/SyncUtil.java | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java index c24ff7de..b9493634 100644 --- a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java +++ b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java @@ -68,7 +68,13 @@ public class JdbcTypeUtil { } public static Object typeConvert(String columnName, String value, int sqlType, String mysqlType) { - if (value == null || value.equals("")) { + if (value == null + || (value.equals("") + && !("longtext".equals(mysqlType) + || "text".equals(mysqlType) + || sqlType == Types.CHAR + || sqlType == Types.VARCHAR + || sqlType == Types.LONGVARCHAR))) { return null; } @@ -118,10 +124,8 @@ public class JdbcTypeUtil { value = value.trim().replace(" ", "T"); DateTime dt = new DateTime(value); res = new Date(dt.toDate().getTime()); - } else { - res = null; + break; } - break; case Types.TIME: value = "T" + value; DateTime dt = new DateTime(value); @@ -132,10 +136,8 @@ public class JdbcTypeUtil { value = value.trim().replace(" ", "T"); dt = new DateTime(value); res = new Timestamp(dt.toDate().getTime()); - } else { - res = null; + break; } - break; case Types.CLOB: default: res = value; diff --git a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java index 6be006d2..04305ced 100644 --- a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java +++ b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java @@ -200,7 +200,7 @@ public class SyncUtil { DateTime dt = new DateTime(v); pstmt.setDate(i, new Date(dt.toDate().getTime())); } else { - pstmt.setNull(i, type); + pstmt.setObject(i, value); } } else { pstmt.setNull(i, type); @@ -232,7 +232,7 @@ public class SyncUtil { DateTime dt = new DateTime(v); pstmt.setTimestamp(i, new Timestamp(dt.toDate().getTime())); } else { - pstmt.setNull(i, type); + pstmt.setObject(i, value); } } else { pstmt.setNull(i, type);