diff --git a/lib/addax-rdbms/src/main/java/com/wgzhao/addax/rdbms/writer/CommonRdbmsWriter.java b/lib/addax-rdbms/src/main/java/com/wgzhao/addax/rdbms/writer/CommonRdbmsWriter.java index 75da4402f..81c8a0d11 100644 --- a/lib/addax-rdbms/src/main/java/com/wgzhao/addax/rdbms/writer/CommonRdbmsWriter.java +++ b/lib/addax-rdbms/src/main/java/com/wgzhao/addax/rdbms/writer/CommonRdbmsWriter.java @@ -470,16 +470,6 @@ protected PreparedStatement fillPreparedStatementColumnType(PreparedStatement pr java.util.Date utilDate; switch (columnSqlType) { case Types.CLOB: - if (dataBaseType.equals(DataBaseType.Oracle) && column.asString().length() >= 4000) { - Clob clob = preparedStatement.getConnection().createClob(); - clob.setString(1, column.asString()); - preparedStatement.setClob(columnIndex, clob); - } - else { - preparedStatement.setString(columnIndex, column.asString()); - } - break; - case Types.CHAR: case Types.NCHAR: case Types.NCLOB: diff --git a/plugin/writer/oraclewriter/src/main/java/com/wgzhao/addax/plugin/writer/oraclewriter/OracleWriter.java b/plugin/writer/oraclewriter/src/main/java/com/wgzhao/addax/plugin/writer/oraclewriter/OracleWriter.java index 1e7f5b2b4..d69828d17 100644 --- a/plugin/writer/oraclewriter/src/main/java/com/wgzhao/addax/plugin/writer/oraclewriter/OracleWriter.java +++ b/plugin/writer/oraclewriter/src/main/java/com/wgzhao/addax/plugin/writer/oraclewriter/OracleWriter.java @@ -20,6 +20,7 @@ package com.wgzhao.addax.plugin.writer.oraclewriter; import com.wgzhao.addax.common.base.Key; +import com.wgzhao.addax.common.element.Column; import com.wgzhao.addax.common.exception.AddaxException; import com.wgzhao.addax.common.plugin.RecordReceiver; import com.wgzhao.addax.common.spi.Writer; @@ -28,6 +29,10 @@ import com.wgzhao.addax.rdbms.util.DataBaseType; import com.wgzhao.addax.rdbms.writer.CommonRdbmsWriter; +import java.sql.Clob; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; import java.util.List; public class OracleWriter @@ -100,7 +105,21 @@ public static class Task public void init() { this.writerSliceConfig = getPluginJobConf(); - this.commonRdbmsWriterTask = new CommonRdbmsWriter.Task(DATABASE_TYPE); + this.commonRdbmsWriterTask = new CommonRdbmsWriter.Task(DATABASE_TYPE) { + @Override + protected PreparedStatement fillPreparedStatementColumnType(PreparedStatement preparedStatement, int columnIndex, int columnSqlType, Column column) + throws SQLException + { + if (writerSliceConfig.getString(Key.WRITE_MODE, "").startsWith("update") && columnSqlType == Types.CLOB ) { + Clob clob = preparedStatement.getConnection().createClob(); + clob.setString(1, column.asString()); + preparedStatement.setClob(columnIndex, clob); + return preparedStatement; + } + + return super.fillPreparedStatementColumnType(preparedStatement, columnIndex, columnSqlType, column); + } + }; commonRdbmsWriterTask.init(writerSliceConfig); }