tursodatabase/turso · error · java.sql.SQLException
Exception while binding double value at position
Error message
Exception while binding double value at position {position} What it means
bindDouble(position, value) throws when the native bind returns a non-zero result code; as with the other bind methods the dominant cause is an out-of-range (non-1-based or too large) parameter position. Both Float and Double values funnel here through bindObject, so setObject calls with either type surface this same error.
Solutions
- Use 1-based positions bounded by stmt.parameterCount()
- Validate position once in a shared helper for all typed binds
- Keep the SQL string and bind calls together so they change together
Example fix
// before
stmt.bindDouble(0, 1.5); // throws
// after
if (position >= 1 && position <= stmt.parameterCount()) {
stmt.bindDouble(position, 1.5);
} Defensive patterns
Strategy: validation
Validate before calling
int paramCount = stmt.parameterCount();
if (position < 1 || position > paramCount) {
throw new IllegalArgumentException("bind position must be 1.." + paramCount);
}
stmt.bindDouble(position, value); Try / catch
try {
stmt.bindDouble(position, value);
} catch (SQLException e) {
throw new IllegalArgumentException(
"bind failed for position " + position + " (1-based, max " + safeParamCount(stmt) + ")", e);
} Prevention
- Use one shared position-validation helper for all typed binds
- Remember Float and Double both funnel into bindDouble via bindObject
- Keep SQL text and binds together so edits stay synchronized
When it happens
Trigger: bindDouble(0, v) or a position above the number of placeholders; binding on a stale statement pointer; occasionally a non-numeric conversion failure inside the native layer.
Common situations: 0-based positions from ported code; placeholder count changed by a SQL edit; reusing statements across connection lifecycle events.
Related errors
- Exception while binding blob value at position
- Exception while binding long value at position
- Exception while binding NULL value at position
- Exception while binding text value at position
- Unsupported object type in bindObject
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/29e86f3f9d122c23.
Report an issue: GitHub.
Appendix: source
Thrown at bindings/java/src/main/java/tech/turso/core/TursoStatement.java:172
throw new SQLException("Exception while binding long value at position " + position);
}
return result;
}
private native int bindLong(long statementPointer, int position, long value) throws SQLException;
/**
* Binds a double value to the prepared statement at the specified position.
*
* @param position The index of the SQL parameter to be set.
* @param value The value to bind to the parameter.
* @return <a href="https://www.sqlite.org/c3ref/c_abort.html">Result Codes</a>
* @throws SQLException If a database access error occurs.
*/
public int bindDouble(int position, double value) throws SQLException {
final int result = bindDouble(statementPointer, position, value);
if (result != 0) {
throw new SQLException("Exception while binding double value at position " + position);
}
return result;
}
private native int bindDouble(long statementPointer, int position, double value)
throws SQLException;
/**
* Binds a text value to the prepared statement at the specified position.
*
* @param position The index of the SQL parameter to be set.
* @param value The value to bind to the parameter.
* @return <a href="https://www.sqlite.org/c3ref/c_abort.html">Result Codes</a>
* @throws SQLException If a database access error occurs.
*/
public int bindText(int position, String value) throws SQLException {
final int result = bindText(statementPointer, position, value);
if (result != 0) {View on GitHub (pinned to 244cde92a7)