mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 11:11:08 +08:00
Merge 692a95692d
into 0824b45c5e
This commit is contained in:
commit
f7a22d34e9
@ -98,6 +98,7 @@ public class DateColumn extends Column {
|
||||
* */
|
||||
public DateColumn(final java.sql.Timestamp ts) {
|
||||
this(ts == null ? null : ts.getTime());
|
||||
this.setRawNano(ts == null ? 0 : ts.getNanos());
|
||||
this.setSubType(DateType.DATETIME);
|
||||
}
|
||||
|
||||
@ -123,8 +124,10 @@ public class DateColumn extends Column {
|
||||
if (null == this.getRawData()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Date((Long)this.getRawData());
|
||||
java.sql.Timestamp myts = new java.sql.Timestamp((Long) this.getRawData());
|
||||
myts.setNanos(this.getRawNano());
|
||||
return myts;
|
||||
// return new Date((Long)this.getRawData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,4 +172,14 @@ public class DateColumn extends Column {
|
||||
public void setSubType(DateType subType) {
|
||||
this.subType = subType;
|
||||
}
|
||||
|
||||
public int getRawNano(){
|
||||
return rawNano;
|
||||
}
|
||||
|
||||
public void setRawNano(int rawNano){
|
||||
this.rawNano = rawNano;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -305,8 +305,8 @@ public class SingleTableSplitUtil {
|
||||
String pkRangeSQL = String.format(minMaxTemplate, splitPK, splitPK,
|
||||
table);
|
||||
if (StringUtils.isNotBlank(where)) {
|
||||
pkRangeSQL = String.format("%s WHERE (%s AND %s IS NOT NULL)",
|
||||
pkRangeSQL, where, splitPK);
|
||||
pkRangeSQL = String.format("%s WHERE (%s)",
|
||||
pkRangeSQL, where);
|
||||
}
|
||||
return pkRangeSQL;
|
||||
}
|
||||
@ -410,4 +410,4 @@ public class SingleTableSplitUtil {
|
||||
}
|
||||
return rangeSql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -507,17 +507,20 @@ public class CommonRdbmsWriter {
|
||||
|
||||
case Types.TIMESTAMP:
|
||||
java.sql.Timestamp sqlTimestamp = null;
|
||||
java.sql.Timestamp tsNano = null;
|
||||
try {
|
||||
utilDate = column.asDate();
|
||||
// utilDate = column.asDate();
|
||||
tsNano = (java.sql.Timestamp)(column.asDate());
|
||||
} catch (DataXException e) {
|
||||
throw new SQLException(String.format(
|
||||
"TIMESTAMP 类型转换错误:[%s]", column));
|
||||
}
|
||||
|
||||
if (null != utilDate) {
|
||||
sqlTimestamp = new java.sql.Timestamp(
|
||||
utilDate.getTime());
|
||||
}
|
||||
// if (null != utilDate) {
|
||||
// sqlTimestamp = new java.sql.Timestamp(
|
||||
// utilDate.getTime());
|
||||
// }
|
||||
sqlTimestamp=tsNano;
|
||||
preparedStatement.setTimestamp(columnIndex + 1, sqlTimestamp);
|
||||
break;
|
||||
|
||||
@ -536,7 +539,7 @@ public class CommonRdbmsWriter {
|
||||
// warn: bit(1) -> Types.BIT 可使用setBoolean
|
||||
// warn: bit(>1) -> Types.VARBINARY 可使用setBytes
|
||||
case Types.BIT:
|
||||
if (this.dataBaseType == DataBaseType.MySql) {
|
||||
if (this.dataBaseType == DataBaseType.MySql || this.dataBaseType == DataBaseType.OceanBase) {
|
||||
preparedStatement.setBoolean(columnIndex + 1, column.asBoolean());
|
||||
} else {
|
||||
preparedStatement.setString(columnIndex + 1, column.asString());
|
||||
|
Loading…
Reference in New Issue
Block a user