mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 09:34:18 +01:00
Feat(jdbc): Implement setObject(int, Object) in JDBC4PreparedStatement
This commit is contained in:
@@ -26,7 +26,9 @@ import java.util.Calendar;
|
|||||||
import tech.turso.annotations.SkipNullableCheck;
|
import tech.turso.annotations.SkipNullableCheck;
|
||||||
import tech.turso.core.TursoResultSet;
|
import tech.turso.core.TursoResultSet;
|
||||||
|
|
||||||
/** JDBC 4 PreparedStatement implementation for Turso databases. */
|
/**
|
||||||
|
* JDBC 4 PreparedStatement implementation for Turso databases.
|
||||||
|
*/
|
||||||
public final class JDBC4PreparedStatement extends JDBC4Statement implements PreparedStatement {
|
public final class JDBC4PreparedStatement extends JDBC4Statement implements PreparedStatement {
|
||||||
|
|
||||||
private final String sql;
|
private final String sql;
|
||||||
@@ -189,7 +191,45 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setObject(int parameterIndex, Object x) throws SQLException {
|
public void setObject(int parameterIndex, Object x) throws SQLException {
|
||||||
// TODO
|
requireNonNull(this.statement);
|
||||||
|
if (x == null) {
|
||||||
|
this.statement.bindNull(parameterIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (x instanceof String) {
|
||||||
|
setString(parameterIndex, (String) x);
|
||||||
|
} else if (x instanceof Integer) {
|
||||||
|
setInt(parameterIndex, (Integer) x);
|
||||||
|
} else if (x instanceof Long) {
|
||||||
|
setLong(parameterIndex, (Long) x);
|
||||||
|
} else if (x instanceof Boolean) {
|
||||||
|
setBoolean(parameterIndex, (Boolean) x);
|
||||||
|
} else if (x instanceof Double) {
|
||||||
|
setDouble(parameterIndex, (Double) x);
|
||||||
|
} else if (x instanceof Float) {
|
||||||
|
setFloat(parameterIndex, (Float) x);
|
||||||
|
} else if (x instanceof Byte) {
|
||||||
|
setByte(parameterIndex, (Byte) x);
|
||||||
|
} else if (x instanceof Short) {
|
||||||
|
setShort(parameterIndex, (Short) x);
|
||||||
|
} else if (x instanceof byte[]) {
|
||||||
|
setBytes(parameterIndex, (byte[]) x);
|
||||||
|
} else if (x instanceof java.sql.Timestamp) {
|
||||||
|
setTimestamp(parameterIndex, (java.sql.Timestamp) x);
|
||||||
|
} else if (x instanceof java.sql.Date) {
|
||||||
|
setDate(parameterIndex, (java.sql.Date) x);
|
||||||
|
} else if (x instanceof java.sql.Time) {
|
||||||
|
setTime(parameterIndex, (java.sql.Time) x);
|
||||||
|
} else if (x instanceof java.math.BigDecimal) {
|
||||||
|
setBigDecimal(parameterIndex, (java.math.BigDecimal) x);
|
||||||
|
} else if (x instanceof Blob || x instanceof Clob || x instanceof InputStream || x instanceof Reader) {
|
||||||
|
throw new SQLException(
|
||||||
|
"setObject does not yet support LOB or Stream types because the corresponding set methods are unimplemented. Type found: "
|
||||||
|
+ x.getClass().getName()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new SQLException("Unsupported object type in setObject: " + x.getClass().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -211,7 +251,8 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCharacterStream(int parameterIndex, Reader reader, int length)
|
public void setCharacterStream(int parameterIndex, Reader reader, int length)
|
||||||
throws SQLException {}
|
throws SQLException {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRef(int parameterIndex, Ref x) throws SQLException {
|
public void setRef(int parameterIndex, Ref x) throws SQLException {
|
||||||
|
|||||||
Reference in New Issue
Block a user