private int getColumnType(int column, SWIGTYPE_p_sqlite3_stmt handle) throws SQLiteException { checkColumn(column, handle, false); if (Internal.isFineLogging()) Internal.logFine(this, "columnType(" + column + ")"); int valueType = _SQLiteSwigged.sqlite3_column_type(handle, column); if (Internal.isFineLogging()) Internal.logFine(this, "columnType(" + column + ")=" + valueType); return valueType; }
/** * Rolls back current transaction. This method is called after exception is caught from a job, or after * job is cancelled. Override to change how to handle these two situations. */ protected void rollback() { if (Internal.isFineLogging()) { Internal.logFine(this, "rolling back transaction"); } try { myConnection.exec("ROLLBACK"); } catch (SQLiteException e) { if (Internal.isFineLogging()) { Internal.logFine(this, "exception during rollback: " + e); } } }
/** * Creates an instance of SQLiteException. * * @param errorCode codes are defined in {@link SQLiteConstants} * @param errorMessage optional error message * @param cause error cause */ public SQLiteException(int errorCode, String errorMessage, Throwable cause) { super("[" + errorCode + "] " + (errorMessage == null ? "sqlite error" : errorMessage), cause); myErrorCode = errorCode; if (Internal.isFineLogging()) { Internal.logFine(getClass(), getMessage()); } }
private void stepResult(int rc, String methodName) throws SQLiteException { if (!myStepped) { // if this is a first step, the statement may have been recompiled and column count changed myColumnCount = -1; } myStepped = true; if (rc == SQLITE_ROW) { if (Internal.isFineLogging()) Internal.logFine(this, methodName + " ROW"); myHasRow = true; } else if (rc == SQLITE_DONE) { if (Internal.isFineLogging()) Internal.logFine(this, methodName + " DONE"); myHasRow = false; } else { myController.throwResult(rc, methodName + "()", this); } }
private void processJobError(Throwable e) throws Throwable { synchronized (myLock) { if (e instanceof SQLiteInterruptedException) { myState = CANCELLED; if (Internal.isFineLogging()) { Internal.log(Level.FINE, this, "cancelled", e); } } else { Internal.log(Level.WARNING, this, "job exception", e); myError = e; myState = ERROR; throw e; } } }
private void finalizeStatement(SWIGTYPE_p_sqlite3_stmt handle, SQLParts sql) { if (Internal.isFineLogging()) Internal.logFine(this, "finalizing cached stmt for " + sql); softFinalize(handle, sql); synchronized (myLock) { forgetCachedHandle(handle, sql); } }
private void finalizeStep(ProgressHandler ph, String methodName) { synchronized (this) { myProgressHandler = null; } if (ph != null) { if (Internal.isFineLogging()) Internal.logFine(this, methodName + " " + ph.getSteps() + " steps"); ph.reset(); } }
/** * Disposes the connection. Override to change how connection is disposed. * * @param connection database connection no longer in use by the queue */ protected void disposeConnection(SQLiteConnection connection) { try { if (connection != null) { if (Internal.isFineLogging()) { Internal.logFine(this, "disposing " + connection); } connection.dispose(); } } catch (Exception e) { Internal.log(Level.SEVERE, this, "error disposing connection", e); } }
/** * Gets a name of the column's table's database in the result set. * * @param column the index of the column, starting with 0 * @return name of the database that contains the table that the column belongs to * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/column_database_name.html">sqlite3_column_database_name</a> */ public String getColumnDatabaseName(int column) throws SQLiteException { myController.validate(); SWIGTYPE_p_sqlite3_stmt handle = handle(); checkColumn(column, handle, false); if (Internal.isFineLogging()) Internal.logFine(this, "columnDatabaseName(" + column + ")"); String r = _SQLiteSwigged.sqlite3_column_database_name(handle, column); if (Internal.isFineLogging()) Internal.logFine(this, "columnDatabaseName(" + column + ")=" + r); return r; }
/** * Gets a name of the column in the result set. * * @param column the index of the column, starting with 0 * @return column name * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/column_name.html">sqlite3_column_name</a> */ public String getColumnName(int column) throws SQLiteException { myController.validate(); SWIGTYPE_p_sqlite3_stmt handle = handle(); checkColumn(column, handle, false); if (Internal.isFineLogging()) Internal.logFine(this, "columnName(" + column + ")"); String r = _SQLiteSwigged.sqlite3_column_name(handle, column); if (Internal.isFineLogging()) Internal.logFine(this, "columnName(" + column + ")=" + r); return r; }
public void close() throws IOException { try { myController.validate(); DirectBuffer buffer = myBuffer; if (buffer == null) return; if (Internal.isFineLogging()) Internal.logFine(SQLiteStatement.this, "BindStream.close:bind([" + buffer.data().capacity() + "])"); int rc = _SQLiteManual.wrapper_bind_buffer(handle(), myIndex, buffer); dispose(); myController.throwResult(rc, "bind(buffer)", SQLiteStatement.this); } catch (SQLiteException e) { throw new IOException("cannot write: " + e); } }
private int getColumnCount(SWIGTYPE_p_sqlite3_stmt handle) { int cc = myColumnCount; if (cc < 0) { // data_count seems more safe than column_count Internal.logFine(this, "asking column count"); myColumnCount = cc = _SQLiteSwigged.sqlite3_column_count(handle); if (cc < 0) { Internal.recoverableError(this, "columnsCount=" + cc, true); cc = 0; } else if (Internal.isFineLogging()) { Internal.logFine(this, "columnCount=" + cc); } } return cc; }
/** * Returns meta information about a specific column of a database table. * * @param dbName database name or {@code null} * @param tableName table name * @param columnName column name * @return SQLiteColumnMetadata column metadata * @throws SQLiteException if specified table is actually a view, or if error occurs during this process, or if the requested table or column cannot be found, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/table_column_metadata.html">sqlite3_table_column_metadata</a> */ public SQLiteColumnMetadata getTableColumnMetadata(String dbName, String tableName, String columnName) throws SQLiteException { checkThread(); if (Internal.isFineLogging()) Internal.logFine(this, "calling sqlite3_table_column_metadata [" + dbName + "," + tableName + "," + columnName + "]"); return mySQLiteManual.sqlite3_table_column_metadata(handle(), dbName, tableName, columnName); }
/** * Repositions BLOB to another row in the table. It should be quickier that closing the blob and opening another one. * * @param rowid row id to move to - it must exist and contain data * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/blob_reopen.html">sqlite3_blob_reopen</a> */ public void reopen(long rowid) throws SQLiteException { myController.validate(); if (Internal.isFineLogging()) Internal.logFine(this, "reopen[" + rowid + "]"); int rc = _SQLiteSwigged.sqlite3_blob_reopen(handle(), rowid); myController.throwResult(rc, "reopen", this); }
private SWIGTYPE_p_intarray_module getIntArrayModule(SWIGTYPE_p_sqlite3 handle) throws SQLiteException { SWIGTYPE_p_intarray_module r = myIntArrayModule; // single-thread: we may be sure of singularity if (r == null) { if (Internal.isFineLogging()) Internal.logFine(this, "registering INTARRAY module"); myIntArrayModule = r = mySQLiteManual.sqlite3_intarray_register(handle); throwResult(mySQLiteManual.getLastReturnCode(), "getIntArrayModule()"); if (r == null) { throwResult(SQLiteConstants.WRAPPER_WEIRD, "getIntArrayModule()"); } } return r; }
/** * Enables or disables SQLite extension loading for this connection. By default, extension loading is disabled. * * @param enabled if true, extensions can be loaded via {@link #loadExtension} function * @throws SQLiteException if extension loading flag cannot be changed * @see <a href="http://www.sqlite.org/c3ref/enable_load_extension.html">enable_load_extension</a> */ public void setExtensionLoadingEnabled(boolean enabled) throws SQLiteException { checkThread(); int rc = _SQLiteSwigged.sqlite3_enable_load_extension(handle(), enabled ? 1 : 0); throwResult(rc, "enableLoadExtension()"); if (Internal.isFineLogging()) { Internal.logFine(this, enabled ? "Extension load enabled" : "Extension load disabled"); } }
/** * Binds SQL parameter to a NULL value. * * @param index the index of the boundable parameter, starting with 1 * @return this object * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">sqlite3_bind_null</a> */ public SQLiteStatement bindNull(int index) throws SQLiteException { myController.validate(); if (Internal.isFineLogging()) Internal.logFine(this, "bind_null(" + index + ")"); int rc = _SQLiteSwigged.sqlite3_bind_null(handle(), index); myController.throwResult(rc, "bind(null)", this); // specifically does not set myHasBindings to true return this; }
/** * Binds SQL parameter to a value of type double. * * @param index the index of the boundable parameter, starting with 1 * @param value non-null double value * @return this object * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">sqlite3_bind_double</a> */ public SQLiteStatement bind(int index, double value) throws SQLiteException { myController.validate(); if (Internal.isFineLogging()) Internal.logFine(this, "bind(" + index + "," + value + ")"); int rc = _SQLiteSwigged.sqlite3_bind_double(handle(), index, value); myController.throwResult(rc, "bind(double)", this); myHasBindings = true; return this; }
/** * Binds SQL parameter to a value of type int. * * @param index the index of the boundable parameter, starting with 1 * @param value non-null int value * @return this object * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">sqlite3_bind_int</a> */ public SQLiteStatement bind(int index, int value) throws SQLiteException { myController.validate(); if (Internal.isFineLogging()) Internal.logFine(this, "bind(" + index + "," + value + ")"); int rc = _SQLiteSwigged.sqlite3_bind_int(handle(), index, value); myController.throwResult(rc, "bind(int)", this); myHasBindings = true; return this; }
/** * Binds SQL parameter to a value of type long. * * @param index the index of the boundable parameter, starting with 1 * @param value non-null long value * @return this object * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">sqlite3_bind_int64</a> */ public SQLiteStatement bind(int index, long value) throws SQLiteException { myController.validate(); if (Internal.isFineLogging()) Internal.logFine(this, "bind(" + index + "," + value + ")"); int rc = _SQLiteSwigged.sqlite3_bind_int64(handle(), index, value); myController.throwResult(rc, "bind(long)", this); myHasBindings = true; return this; }