Implement bindXXX functions on rust and java side

This commit is contained in:
김선우
2025-02-07 11:25:23 +09:00
parent d574e2c277
commit 21d6f33c6b
3 changed files with 306 additions and 16 deletions

View File

@@ -97,14 +97,106 @@ public class LimboStatement {
* @throws SQLException if a database access error occurs while retrieving column names
*/
public void initializeColumnMetadata() throws SQLException {
final String[] columnNames = this.columnNames(statementPointer);
final String[] columnNames = this.columns(statementPointer);
if (columnNames != null) {
this.resultSet.setColumnNames(columnNames);
}
}
@Nullable
private native String[] columnNames(long statementPointer) throws SQLException;
private native String[] columns(long statementPointer) throws SQLException;
/**
* Binds a NULL value to the prepared statement at the specified position.
*
* @param position The index of the SQL parameter to be set to NULL.
* @return <a href="https://www.sqlite.org/c3ref/c_abort.html">Result Codes</a>
* @throws SQLException If a database access error occurs.
*/
public int bindNull(int position) throws SQLException {
final int result = bindNull(statementPointer, position);
if (result != 0) {
throw new SQLException("Exception while binding NULL value at position " + position);
}
return result;
}
private native int bindNull(long statementPointer, int position) throws SQLException;
/**
* Binds a long 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 bindLong(int position, long value) throws SQLException {
final int result = bindLong(statementPointer, position, value);
if (result != 0) {
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) {
throw new SQLException("Exception while binding text value at position " + position);
}
return result;
}
private native int bindText(long statementPointer, int position, String value)
throws SQLException;
/**
* Binds a blob 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 bindBlob(int position, byte[] value) throws SQLException {
final int result = bindBlob(statementPointer, position, value);
if (result != 0) {
throw new SQLException("Exception while binding blob value at position " + position);
}
return result;
}
private native int bindBlob(long statementPointer, int position, byte[] value)
throws SQLException;
/**
* Checks if the statement is closed.