Skip to content

Commit

Permalink
upgrade mysql driver
Browse files Browse the repository at this point in the history
  • Loading branch information
agapple committed Jun 30, 2015
1 parent b2006c2 commit 716dffd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private DataSource createDataSource(String url, String userName, String password
dbcpDs.addConnectionProperty("rewriteBatchedStatements", "true");
dbcpDs.addConnectionProperty("zeroDateTimeBehavior", "convertToNull");// 将0000-00-00的时间类型返回null
dbcpDs.addConnectionProperty("yearIsDateType", "false");// 直接返回字符串,不做year转换date处理
dbcpDs.addConnectionProperty("noDatetimeStringSync", "true");// 返回时间类型的字符串,不做时区处理
if (StringUtils.isNotEmpty(encoding)) {
dbcpDs.addConnectionProperty("characterEncoding", encoding);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,21 @@ private static String getResultSetValue(ResultSet rs, int index, Class<?> requir
// value = rs.getTime(index);
// } catch (SQLException e) {
value = rs.getString(index);// 尝试拿为string对象,0000无法用Time表示
if (value == null && !rs.wasNull()) {
value = "00:00:00"; // mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null
}
// if (value == null && !rs.wasNull()) {
// value = "00:00:00"; //
// mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null
// }
// }
} else if (java.sql.Timestamp.class.equals(requiredType) || java.sql.Date.class.equals(requiredType)) {
// try {
// value = convertTimestamp(rs.getTimestamp(index));
// } catch (SQLException e) {
// 尝试拿为string对象,0000-00-00 00:00:00无法用Timestamp 表示
value = rs.getString(index);
if (value == null && !rs.wasNull()) {
value = "0000:00:00 00:00:00"; // mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null
}
// if (value == null && !rs.wasNull()) {
// value = "0000:00:00 00:00:00"; //
// mysql设置了zeroDateTimeBehavior=convertToNull,出现0值时返回为null
// }
// }
} else if (BigDecimal.class.equals(requiredType)) {
value = rs.getBigDecimal(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import com.alibaba.otter.node.etl.select.selector.MessageDumper;
import com.alibaba.otter.node.etl.select.selector.MessageParser;
import com.alibaba.otter.node.etl.select.selector.OtterSelector;
import com.alibaba.otter.shared.common.model.config.channel.ChannelParameter.SyncMode;
import com.alibaba.otter.shared.common.model.config.data.DataMedia.ModeValue;
import com.alibaba.otter.shared.common.model.config.data.DataMediaPair;
import com.alibaba.otter.shared.common.model.config.pipeline.Pipeline;
Expand Down Expand Up @@ -115,7 +114,8 @@ public void start() {
batchSize = pipeline.getParameters().getMainstemBatchsize();
batchTimeout = pipeline.getParameters().getBatchTimeout();
ddlSync = pipeline.getParameters().getDdlSync();
final SyncMode syncMode = pipeline.getParameters().getSyncMode();
final boolean syncFull = pipeline.getParameters().getSyncMode().isRow()
|| pipeline.getParameters().isEnableRemedy();
// 暂时使用skip load代替
filterTableError = pipeline.getParameters().getSkipSelectException();
if (pipeline.getParameters().getDumpSelector() != null) {
Expand Down Expand Up @@ -162,7 +162,7 @@ protected void startEventParserInternal(CanalEventParser parser, boolean isGroup
if (eventParser instanceof MysqlEventParser) {
// 设置支持的类型
((MysqlEventParser) eventParser).setSupportBinlogFormats("ROW");
if (syncMode.isRow()) {
if (syncFull) {
((MysqlEventParser) eventParser).setSupportBinlogImages("FULL");
} else {
((MysqlEventParser) eventParser).setSupportBinlogImages("FULL,MINIMAL");
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<file_encoding>UTF-8</file_encoding>
<spring-version>3.1.2.RELEASE</spring-version>
<jetty_verion>8.1.7.v20120910</jetty_verion>
<otter_canal_version>1.0.20-SNAPSHOT</otter_canal_version>
<otter_canal_version>1.0.20</otter_canal_version>
</properties>

<modules>
Expand Down Expand Up @@ -213,7 +213,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.12</version>
<version>5.1.35</version>
</dependency>
<!-- oracle -->
<dependency>
Expand Down

0 comments on commit 716dffd

Please sign in to comment.