You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try (PreparedStatements = connection.prepareStatement(
""" SELECT cast(? as blob sub_type text) FROM rdb$database """
)) {
s.setClob(1, (Clob) null);
try (ResultSetrs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getString(1));
}
}
It produces:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.sql.Clob.getCharacterStream()" because "clob" is null
at org.firebirdsql.jdbc.AbstractPreparedStatement.setClob(AbstractPreparedStatement.java:723)
at org.jooq.testscripts.JDBC.main(JDBC.java:71)
This works:
try (PreparedStatements = connection.prepareStatement(
""" SELECT cast(? as blob sub_type text) FROM rdb$database """
)) {
s.setNull(1, Types.CLOB);
try (ResultSetrs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getString(1));
}
}
And so does this:
try (PreparedStatements = connection.prepareStatement(
""" SELECT cast(? as blob sub_type text) FROM rdb$database """
)) {
s.setString(1, null);
try (ResultSetrs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getString(1));
}
}
Other drivers support null values on the setClob() (or setBlob()) methods. I don't think the behaviour is ambiguous. In fact, I think it's inconsistent with ResultSet behaviour:
try (PreparedStatements = connection.prepareStatement(
""" SELECT cast(? as blob sub_type text) FROM rdb$database """
)) {
s.setString(1, null);
try (ResultSetrs = s.executeQuery()) {
while (rs.next())
System.out.println(rs.getClob(1));
}
}
When fetching the CLOB value, the ResultSet returns a null value, so it should be possible to bind it as well.
The text was updated successfully, but these errors were encountered:
Try this code:
It produces:
This works:
And so does this:
Other drivers support
null
values on thesetClob()
(orsetBlob()
) methods. I don't think the behaviour is ambiguous. In fact, I think it's inconsistent withResultSet
behaviour:When fetching the
CLOB
value, theResultSet
returns anull
value, so it should be possible to bind it as well.The text was updated successfully, but these errors were encountered: