org.sqlite
Class Statement

java.lang.Object
  extended by org.sqlite.Statement

public class Statement
extends java.lang.Object

sqlite3_stmt wrapper class.
NOTE: SQLite 3.3.17 based.

See Also:
Database.prepare(java.lang.String), Database.prepare(java.lang.String, org.sqlite.swig.SQLite3.SQLite3StmtPtrPtr), Database.prepareMultiple(java.lang.String)

Method Summary
 void bindBytes(int parameterIndex, byte[] val)
          invoke sqlite3_bind_blob() function.
 void bindBytes(int parameterIndex, byte[] val, int len)
          invoke sqlite3_bind_blob() function.
 void bindDouble(int parameterIndex, double val)
          invoke sqlite3_bind_double() function.
 void bindInt(int parameterIndex, int val)
          invoke sqlite3_bind_int() function.
 void bindLong(int parameterIndex, long val)
          invoke sqlite3_bind_int64() function.
 void bindNull(int parameterIndex)
          invoke sqlite3_bind_null() function.
 void bindText(int parameterIndex, java.lang.String val)
          invoke sqlite3_bind_text() function.
 void bindValue(int parameterIndex, SWIGTYPE_p_Mem val)
          invoke sqlite3_bind_value() function.
 void clearBinding()
          invoke sqlite3_clear_bindings() function.
 void close()
          invoke sqlite3_finalize() function.
 int execute()
          invoke step() method.
protected  void finalize()
          Close statement if statement is not closed yet.
 SWIGTYPE_p_void getBlob(int columnIndex)
          invoke sqlite3_column_blob() function.
 int getByteLength(int columnIndex)
          invoke sqlite3_column_bytes() function.
 byte[] getBytes(int columnIndex)
          invoke sqlite3_column_blob() function.
 int getColumnCount()
          invoke sqlite3_column_count() function.
 java.lang.String getColumnDatabaseName(int columnIndex)
          invoke sqlite3_column_database_name() function.
 java.lang.String getColumnLabel(int columnIndex)
          invoke sqlite3_column_name() function.
 java.lang.String getColumnName(int columnIndex)
          invoke sqlite3_column_origin_name() function.
 java.lang.String getColumnTableName(int columnIndex)
          invoke sqlite3_column_table_name() function.
 int getColumnType(int columnIndex)
          invoke sqlite3_column_type() function.
NOTE: Required to invoke the step() method beforehand.
 java.lang.String getColumnTypeName(int columnIndex)
          invoke sqlite3_column_decltype() function.
 Database getDatabase()
          Retrieves the Database object that produced this Statement object.
 int getDataCount()
          invoke sqlite3_data_count() function.
NOTE: Required to invoke the step() method beforehand.
 SWIGTYPE_p_sqlite3 getDbHandle()
          invoke sqlite3_db_handle() function.
 double getDouble(int columnIndex)
          invoke sqlite3_column_double() function.
 int getInt(int columnIndex)
          invoke sqlite3_column_int() function.
 long getLong(int columnIndex)
          invoke sqlite3_column_int64() function.
 int getParameterCount()
          invoke sqlite3_bind_parameter_count() function.
 int getParameterIndex(java.lang.String parameterName)
          invoke sqlite3_bind_parameter_index() function.
 java.lang.String getParameterName(int parameterIndex)
          invoke sqlite3_bind_parameter_name() function.
 java.lang.String getString(int columnIndex)
          invoke sqlite3_column_text() function.
 SWIGTYPE_p_Mem getValue(int columnIndex)
          invoke sqlite3_column_value() function.
 boolean isClosed()
          Retrieves whether this Statement object has been closed.
 boolean isExpired()
          Deprecated.  
 boolean isManaged()
          True is returned when generated with PreparedStatement.
 boolean producedResultSet()
          true if the return value of getColumnCount() is not 0.
 void reset()
          invoke sqlite3_reset() function.
 int step()
          invoke sqlite3_step() function.
 void transferBinding(Statement dest)
          Deprecated.  
 void validateColumnIndexRange(int columnIndex)
           
protected  void validateStatementOpen()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isManaged

public boolean isManaged()
True is returned when generated with PreparedStatement.

Returns:
True is returned when generated with PreparedStatement.

getParameterCount

public int getParameterCount()
                      throws java.sql.SQLException
invoke sqlite3_bind_parameter_count() function.

Returns:
parameter count
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Number Of SQL Parameters

getParameterIndex

public int getParameterIndex(java.lang.String parameterName)
                      throws java.sql.SQLException
invoke sqlite3_bind_parameter_index() function.

Parameters:
parameterName - parameter name
Returns:
parameter index
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Index Of A Parameter With A Given Name

getParameterName

public java.lang.String getParameterName(int parameterIndex)
                                  throws java.sql.SQLException
invoke sqlite3_bind_parameter_name() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
parameter name
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Name Of A Host Parameter

getColumnCount

public int getColumnCount()
                   throws java.sql.SQLException
invoke sqlite3_column_count() function.

Returns:
column count
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Number Of Columns In A Result Set

getDataCount

public int getDataCount()
                 throws java.sql.SQLException
invoke sqlite3_data_count() function.
NOTE: Required to invoke the step() method beforehand.

Returns:
data count
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
step(), Number of columns in a result set

getColumnDatabaseName

public java.lang.String getColumnDatabaseName(int columnIndex)
                                       throws java.sql.SQLException
invoke sqlite3_column_database_name() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
database name
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Source Of Data In A Query Result

getColumnLabel

public java.lang.String getColumnLabel(int columnIndex)
                                throws java.sql.SQLException
invoke sqlite3_column_name() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
column label
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Column Names In A Result Set

getColumnName

public java.lang.String getColumnName(int columnIndex)
                               throws java.sql.SQLException
invoke sqlite3_column_origin_name() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
column name
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Source Of Data In A Query Result

getColumnType

public int getColumnType(int columnIndex)
                  throws java.sql.SQLException
invoke sqlite3_column_type() function.
NOTE: Required to invoke the step() method beforehand.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
column type
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
step(), Results Values From A Query

getColumnTableName

public java.lang.String getColumnTableName(int columnIndex)
                                    throws java.sql.SQLException
invoke sqlite3_column_table_name() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
table name
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Source Of Data In A Query Result

getColumnTypeName

public java.lang.String getColumnTypeName(int columnIndex)
                                   throws java.sql.SQLException
invoke sqlite3_column_decltype() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
column declare type name
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Declared Datatype Of A Query Result

getString

public java.lang.String getString(int columnIndex)
                           throws java.sql.SQLException
invoke sqlite3_column_text() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
value of string
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getInt

public int getInt(int columnIndex)
           throws java.sql.SQLException
invoke sqlite3_column_int() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
value of integer
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getLong

public long getLong(int columnIndex)
             throws java.sql.SQLException
invoke sqlite3_column_int64() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
value of long
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getDouble

public double getDouble(int columnIndex)
                 throws java.sql.SQLException
invoke sqlite3_column_double() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
value of double
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getBytes

public byte[] getBytes(int columnIndex)
                throws java.sql.SQLException
invoke sqlite3_column_blob() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
value of byte arrays
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getBlob

public SWIGTYPE_p_void getBlob(int columnIndex)
                        throws java.sql.SQLException
invoke sqlite3_column_blob() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
pointer of BLOB object
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getByteLength

public int getByteLength(int columnIndex)
                  throws java.sql.SQLException
invoke sqlite3_column_bytes() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
the number of bytes
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

getValue

public SWIGTYPE_p_Mem getValue(int columnIndex)
                        throws java.sql.SQLException
invoke sqlite3_column_value() function.

Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
the sqlite3_value* object
Throws:
java.sql.SQLException - When the columnIndex is not valid. When this method is called on a closed connection.
See Also:
Results Values From A Query

bindNull

public void bindNull(int parameterIndex)
              throws java.sql.SQLException
invoke sqlite3_bind_null() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_null() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindInt

public void bindInt(int parameterIndex,
                    int val)
             throws java.sql.SQLException
invoke sqlite3_bind_int() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_int() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindLong

public void bindLong(int parameterIndex,
                     long val)
              throws java.sql.SQLException
invoke sqlite3_bind_int64() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_int64() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindDouble

public void bindDouble(int parameterIndex,
                       double val)
                throws java.sql.SQLException
invoke sqlite3_bind_double() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_double() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindText

public void bindText(int parameterIndex,
                     java.lang.String val)
              throws java.sql.SQLException
invoke sqlite3_bind_text() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_text() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindBytes

public void bindBytes(int parameterIndex,
                      byte[] val)
               throws java.sql.SQLException
invoke sqlite3_bind_blob() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_blob() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements, bindBytes(int, byte[], int)

bindBytes

public void bindBytes(int parameterIndex,
                      byte[] val,
                      int len)
               throws java.sql.SQLException
invoke sqlite3_bind_blob() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the parameter value
len - the number of bytes
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_blob() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

bindValue

public void bindValue(int parameterIndex,
                      SWIGTYPE_p_Mem val)
               throws java.sql.SQLException
invoke sqlite3_bind_value() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
val - the sqlite3_value* object
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_bind_value() function is not SQLITE_OK.
See Also:
Binding Values To Prepared Statements

clearBinding

public void clearBinding()
                  throws java.sql.SQLException
invoke sqlite3_clear_bindings() function.

Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_clear_bindings() function is not SQLITE_OK.
See Also:
Reset All Bindings On A Prepared Statement

reset

public void reset()
           throws java.sql.SQLException
invoke sqlite3_reset() function.

Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_reset() function is not SQLITE_OK.
See Also:
Reset A Prepared Statement Object

step

public int step()
         throws java.sql.SQLException
invoke sqlite3_step() function.

Returns:
SQLITE_DONE or SQLITE_ROW
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_step() function is neither SQLITE_DONE nor SQLITE_ROW.
See Also:
Evaluate An SQL Statement

execute

public int execute()
            throws java.sql.SQLException
invoke step() method.

Returns:
SQLITE_DONE or SQLITE_ROW
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_step() function is neither SQLITE_DONE nor SQLITE_ROW.
See Also:
step()

isExpired

public boolean isExpired()
                  throws java.sql.SQLException
Deprecated. 

invoke sqlite3_expired() function.

Returns:
Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_expired() function is non-zero.
See Also:
sqlite3_expired, Obsolete Functions

getDbHandle

public SWIGTYPE_p_sqlite3 getDbHandle()
                               throws java.sql.SQLException
invoke sqlite3_db_handle() function.

Returns:
pointer of database handle
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
Find The Database Handle Of A Prepared Statement

transferBinding

public void transferBinding(Statement dest)
                     throws java.sql.SQLException
Deprecated. 

invoke sqlite3_transfer_bindings() function.

Throws:
java.sql.SQLException - When this method is called on a closed connection. When the return value of the sqlite3_transfer_bindings() function is not SQLITE_OK.
See Also:
sqlite3_transfer_bindings, Obsolete Functions

producedResultSet

public boolean producedResultSet()
                          throws java.sql.SQLException
true if the return value of getColumnCount() is not 0.

Returns:
true if the return value of getColumnCount() is not 0.
Throws:
java.sql.SQLException - When this method is called on a closed connection.
See Also:
getColumnCount()

isClosed

public boolean isClosed()
Retrieves whether this Statement object has been closed.

Returns:
true if this Statement object is closed; false if it is still open

close

public void close()
           throws java.sql.SQLException
invoke sqlite3_finalize() function.

Throws:
java.sql.SQLException - When the return value of the sqlite3_finalize() function is neither SQLITE_OK nor SQLITE_ABORT.
See Also:
Destroy A Prepared Statement Object

finalize

protected void finalize()
                 throws java.lang.Throwable
Close statement if statement is not closed yet.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

validateStatementOpen

protected void validateStatementOpen()
                              throws java.sql.SQLException
Throws:
java.sql.SQLException - When this method is called on a closed connection.

validateColumnIndexRange

public void validateColumnIndexRange(int columnIndex)
                              throws java.sql.SQLException
Parameters:
columnIndex - the first column is 1, the second is 2, ...
Throws:
java.sql.SQLException - the column index out of range.

getDatabase

public Database getDatabase()
                     throws java.sql.SQLException
Retrieves the Database object that produced this Statement object.

Returns:
Database object
Throws:
java.sql.SQLException - When this method is called on a closed connection.