Skip to content

Commit

Permalink
#822 Delegate to FBField for FBPreparedStatement and FBResultSet
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Sep 25, 2024
1 parent 6bdae77 commit b24e3db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
8 changes: 1 addition & 7 deletions src/main/org/firebirdsql/jdbc/FBPreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,7 @@ public void clearParameters() throws SQLException {
@Override
public void setObject(int parameterIndex, @Nullable Object x, int targetSqlType, int scaleOrLength)
throws SQLException {
if (x instanceof InputStream) {
setBinaryStream(parameterIndex, (InputStream) x, scaleOrLength);
} else if (x instanceof Reader) {
setCharacterStream(parameterIndex, (Reader) x, scaleOrLength);
} else {
setObject(parameterIndex, x);
}
getField(parameterIndex).setObject(x, scaleOrLength);
}

/**
Expand Down
18 changes: 4 additions & 14 deletions src/main/org/firebirdsql/jdbc/FBResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1111,13 +1111,8 @@ public void updateBinaryStream(String columnLabel, @Nullable InputStream x) thro
*/
@Override
public void updateObject(int columnIndex, @Nullable Object x, int scaleOrLength) throws SQLException {
if (x instanceof InputStream) {
updateBinaryStream(columnIndex, (InputStream) x, scaleOrLength);
} else if (x instanceof Reader) {
updateCharacterStream(columnIndex, (Reader) x, scaleOrLength);
} else {
updateObject(columnIndex, x);
}
checkUpdatable();
getField(columnIndex).setObject(x, scaleOrLength);
}

/**
Expand Down Expand Up @@ -1410,13 +1405,8 @@ public void updateNCharacterStream(String columnLabel, @Nullable Reader reader)
*/
@Override
public void updateObject(String columnName, @Nullable Object x, int scaleOrLength) throws SQLException {
if (x instanceof InputStream) {
updateBinaryStream(columnName, (InputStream) x, scaleOrLength);
} else if (x instanceof Reader) {
updateCharacterStream(columnName, (Reader) x, scaleOrLength);
} else {
updateObject(columnName, x);
}
checkUpdatable();
getField(columnName).setObject(x, scaleOrLength);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/main/org/firebirdsql/jdbc/field/FBField.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ public void setObject(Object value) throws SQLException {
}
}

public void setObject(Object value, int scaleOrLength) throws SQLException {
if (value instanceof InputStream) {
setBinaryStream((InputStream) value, scaleOrLength);
} else if (value instanceof Reader) {
setCharacterStream((Reader) value, scaleOrLength);
} else {
setObject(value);
}
}

private void setObjectWithInstanceOf(Object value) throws SQLException {
if (value instanceof BigDecimal bigDecimal) {
setBigDecimal(bigDecimal);
Expand Down

0 comments on commit b24e3db

Please sign in to comment.