mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed merge and blob encoding example
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.alibaba.otter.canal.example;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
@@ -254,7 +254,18 @@ public class AbstractCanalClientTest {
|
||||
protected void printColumn(List<Column> columns) {
|
||||
for (Column column : columns) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(column.getName() + " : " + column.getValue());
|
||||
try {
|
||||
if (StringUtils.containsIgnoreCase(column.getMysqlType(), "BLOB")
|
||||
|| StringUtils.containsIgnoreCase(column.getMysqlType(), "BINARY")) {
|
||||
// get value bytes
|
||||
builder.append(column.getName() + " : "
|
||||
+ new String(column.getValue().getBytes("ISO-8859-1"), "UTF-8"));
|
||||
} else {
|
||||
builder.append(column.getName() + " : " + column.getValue());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
|
||||
builder.append(" type=" + column.getMysqlType());
|
||||
if (column.getUpdated()) {
|
||||
builder.append(" update=" + column.getUpdated());
|
||||
|
||||
Reference in New Issue
Block a user