tursodatabase/turso · error · SQLException
Invalid argument
Error message
Invalid argument
What it means
JDBC4Statement.getMoreResults(int) accepts only Statement.CLOSE_CURRENT_RESULT; any other flag (KEEP_CURRENT_RESULT, CLOSE_ALL_RESULTS) throws SQLException("Invalid argument"). Even the accepted path is single-result only: it closes the current result set, resets updateCount to -1, and always returns false — this driver does not expose multiple result sets per statement.
Solutions
- Call the no-arg getMoreResults(), which defaults to CLOSE_CURRENT_RESULT
- Restructure to one statement per result set; this driver never returns a second one
- Guard the flag: treat any value other than CLOSE_CURRENT_RESULT as an error before calling
- Catch the SQLException when reusing generic multi-result framework code that you cannot change
Example fix
// before
while (stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT)) { ... }
// after
// single result set per statement on this driver
try (ResultSet rs = stmt.getResultSet()) {
while (rs.next()) { ... }
} Defensive patterns
Strategy: validation
Validate before calling
if (current != Statement.CLOSE_CURRENT_RESULT) {
// driver supports only CLOSE_CURRENT_RESULT; single result set per statement
current = Statement.CLOSE_CURRENT_RESULT;
}
boolean more = stmt.getMoreResults(current); Try / catch
try {
return stmt.getMoreResults(current);
} catch (SQLException e) {
if ("Invalid argument".equals(e.getMessage())) {
return false; // driver has no additional result sets anyway
}
throw e;
} Prevention
- Prefer the no-arg getMoreResults() with this driver
- Do not port multi-result-set iteration loops; issue one statement per result set
- Remember the driver always reports a single result set and getUpdateCount is reset to -1
When it happens
Trigger: Calling stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT) or CLOSE_ALL_RESULTS, most often inside the standard JDBC multi-result iteration loop (while (stmt.getMoreResults(...)) after execute()), or inside generic DAO/stored-procedure helpers that preserve the current result set while probing for more.
Common situations: Porting multi-result-set iteration patterns written for MySQL/PostgreSQL/SQL Server drivers; engines or test harnesses that return several result sets per call; framework code that chooses a flag based on configuration.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- Query timeout must be greater than 0
- statement is closed
- Statement is closed
- createBlob not supported
- createClob not supported
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/f5c7d4251623f95c.
Report an issue: GitHub.
Appendix: source
Thrown at bindings/java/src/main/java/tech/turso/jdbc4/JDBC4Statement.java:356
return BATCH_COMPATIBLE_PATTERN.matcher(sql).find();
}
@Override
public Connection getConnection() {
return connection;
}
@Override
public boolean getMoreResults() throws SQLException {
return getMoreResults(Statement.CLOSE_CURRENT_RESULT);
}
@Override
public boolean getMoreResults(int current) throws SQLException {
requireNonNull(statement, "statement should not be null");
if (current != Statement.CLOSE_CURRENT_RESULT) {
throw new SQLException("Invalid argument");
}
statement.getResultSet().close();
updateCount = -1;
return false;
}
@Override
@SkipNullableCheck
public ResultSet getGeneratedKeys() throws SQLException {
// TODO
return null;
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
// TODO: enhanceView on GitHub (pinned to 244cde92a7)