Skip to content

Commit

Permalink
[bugfix][plugin][oraclewriter] Fix closed connection exception caused…
Browse files Browse the repository at this point in the history
… by update a blob field, fix #1092
  • Loading branch information
wgzhao committed Aug 23, 2024
1 parent 89a1834 commit f7bc24c
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.wgzhao.addax.rdbms.util.DataBaseType;
import com.wgzhao.addax.rdbms.writer.CommonRdbmsWriter;

import java.sql.Blob;
import java.sql.Clob;
import java.sql.PreparedStatement;
import java.sql.SQLException;
Expand Down Expand Up @@ -110,11 +111,20 @@ public void init()
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;
if (writerSliceConfig.getString(Key.WRITE_MODE, "").startsWith("update")) {
if (columnSqlType == Types.CLOB ) {
Clob clob = preparedStatement.getConnection().createClob();
clob.setString(1, column.asString());
preparedStatement.setClob(columnIndex, clob);
return preparedStatement;
}
if (columnSqlType == Types.BLOB) {
Blob blob = preparedStatement.getConnection().createBlob();
blob.setBytes(1, column.asBytes());
preparedStatement.setBlob(columnIndex, blob);
return preparedStatement;
}
return super.fillPreparedStatementColumnType(preparedStatement, columnIndex, columnSqlType, column);
}

return super.fillPreparedStatementColumnType(preparedStatement, columnIndex, columnSqlType, column);
Expand Down

0 comments on commit f7bc24c

Please sign in to comment.