apache/shardingsphere · error · SQLFeatureNotSupportedException
getTime
Error message
getTime
What it means
getTime(int columnIndex) is final and always throws in AbstractUnsupportedGeneratedKeysResultSet. The generated-keys result set returned by the ShardingSphere driver implements only getString/getNumeric/getObject families; java.sql.Time extraction from generated keys is not supported because the underlying values are plain Comparables without temporal semantics.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:72
@Override
public final Date getDate(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getDate");
}
@Override
public final Date getDate(final int columnIndex, final Calendar cal) throws SQLException {
throw new SQLFeatureNotSupportedException("getDate");
}
@Override
public final Date getDate(final String columnLabel, final Calendar cal) throws SQLException {
throw new SQLFeatureNotSupportedException("getDate");
}
@Override
public final Time getTime(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getTime");
}
@Override
public final Time getTime(final int columnIndex, final Calendar cal) throws SQLException {
throw new SQLFeatureNotSupportedException("getTime");
}
@Override
public final Time getTime(final String columnLabel, final Calendar cal) throws SQLException {
throw new SQLFeatureNotSupportedException("getTime");
}
@Override
public final Time getTime(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getTime");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Read the key with rs.getString(1) and convert with java.sql.Time.valueOf(String) if it is genuinely a time literal.
- Use rs.getObject(1) and cast/convert in Java.
- Catch SQLFeatureNotSupportedException and fall back to string parsing.
Example fix
// before Time t = rs.getTime(1); // after String raw = rs.getString(1); Time t = raw == null ? null : java.sql.Time.valueOf(raw);
Defensive patterns
Strategy: try-catch
Validate before calling
Object key = rs.getObject(1); // decide conversion from runtime type
Type guard
static boolean isShardingGeneratedKeys(ResultSet rs) {
return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
} Try / catch
try {
t = rs.getTime(1);
} catch (SQLFeatureNotSupportedException e) {
String raw = rs.getString(1);
t = raw == null ? null : java.sql.Time.valueOf(raw);
} Prevention
- Use string reads plus java.sql.Time.valueOf for time-typed generated keys.
- Keep typed temporal getters out of generic generated-key mappers.
- Test insert paths with the ShardingSphere driver in CI.
When it happens
Trigger: Calling rs.getTime(1) while iterating the ResultSet from Statement.getGeneratedKeys() after an INSERT via the ShardingSphere driver.
Common situations: Entity persisters that map generated key columns to arbitrary Java types including Time. Code reused from a MySQL/PostgreSQL project where getTime on generated keys worked.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/c5df3b76409a4584.
Report an issue: GitHub.