diff --git a/bindings/java/src/main/java/tech/turso/jdbc4/JDBC4PreparedStatement.java b/bindings/java/src/main/java/tech/turso/jdbc4/JDBC4PreparedStatement.java index 5b38658cd..744e1c00b 100644 --- a/bindings/java/src/main/java/tech/turso/jdbc4/JDBC4PreparedStatement.java +++ b/bindings/java/src/main/java/tech/turso/jdbc4/JDBC4PreparedStatement.java @@ -22,6 +22,7 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.RowId; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLXML; import java.sql.Time; import java.sql.Timestamp; @@ -435,12 +436,14 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep @Override public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { - // TODO + requireLengthIsPositiveInt(length); + setAsciiStream(parameterIndex, x, (int) length); } @Override public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { - // TODO + requireLengthIsPositiveInt(length); + setBinaryStream(parameterIndex, x, (int) length); } @Override @@ -449,6 +452,13 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep // TODO } + private void requireLengthIsPositiveInt(long length) throws SQLFeatureNotSupportedException { + if (length > Integer.MAX_VALUE || length < 0) { + throw new SQLFeatureNotSupportedException( + "Data must have a length between 0 and Integer.MAX_VALUE"); + } + } + @Override public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { // TODO