Sleuth Kit Java Bindings (JNI)  4.11.1
Java bindings for using The Sleuth Kit
org.sleuthkit.datamodel.CaseDbAccessManager Class Reference

Classes

interface  CaseDbAccessQueryCallback
 
class  CaseDbPreparedStatement
 

Public Member Functions

void alterTable (final String tableName, final String alterSQL) throws TskCoreException
 
void alterTable (final String tableName, final String alterSQL, final CaseDbTransaction transaction) throws TskCoreException
 
boolean columnExists (String tableName, String columnName) throws TskCoreException
 
boolean columnExists (String tableName, String columnName, CaseDbTransaction transaction) throws TskCoreException
 
void createIndex (final String indexName, final String tableName, final String colsSQL) throws TskCoreException
 
void createTable (final String tableName, final String tableSchema) throws TskCoreException
 
void delete (final String tableName, final String sql) throws TskCoreException
 
long insert (final String tableName, final String sql) throws TskCoreException
 
long insert (final String tableName, final String sql, final CaseDbTransaction transaction) throws TskCoreException
 
void insert (CaseDbPreparedStatement preparedStatement) throws TskCoreException
 
long insertOrUpdate (final String tableName, final String sql) throws TskCoreException
 
long insertOrUpdate (final String tableName, final String sql, final CaseDbTransaction transaction) throws TskCoreException
 
CaseDbPreparedStatement prepareInsert (String tableName, String sql, CaseDbTransaction trans) throws TskCoreException
 
CaseDbPreparedStatement prepareSelect (String sql) throws TskCoreException
 
CaseDbPreparedStatement prepareUpdate (String tableName, String sql, CaseDbTransaction trans) throws TskCoreException
 
void select (final String sql, final CaseDbAccessQueryCallback queryCallback) throws TskCoreException
 
void select (CaseDbPreparedStatement preparedStatement, CaseDbAccessQueryCallback queryCallback) throws TskCoreException
 
boolean tableExists (String tableName) throws TskCoreException
 
boolean tableExists (String tableName, CaseDbTransaction transaction) throws TskCoreException
 
void update (CaseDbPreparedStatement preparedStatement) throws TskCoreException
 
void update (final String tableName, final String sql) throws TskCoreException
 
void update (final String tableName, final String sql, CaseDbTransaction transaction) throws TskCoreException
 

Detailed Description

This class provides modules with access to the case database to create custom tables/indexes and to query them.

Definition at line 42 of file CaseDbAccessManager.java.

Member Function Documentation

void org.sleuthkit.datamodel.CaseDbAccessManager.alterTable ( final String  tableName,
final String  alterSQL 
) throws TskCoreException

Alters a table with the specified name.

Parameters
tableNamename of the table to alter
alterSQLSQL to alter the table
Exceptions
TskCoreException

Definition at line 276 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), and org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback().

void org.sleuthkit.datamodel.CaseDbAccessManager.alterTable ( final String  tableName,
final String  alterSQL,
final CaseDbTransaction  transaction 
) throws TskCoreException

Alters a table with the specified name.

Parameters
tableNamename of the table to alter
alterSQLSQL to alter the table
transactiontransaction
Exceptions
TskCoreException

Definition at line 303 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), and org.sleuthkit.datamodel.TskData.DbType.SQLITE.

boolean org.sleuthkit.datamodel.CaseDbAccessManager.columnExists ( String  tableName,
String  columnName 
) throws TskCoreException

Checks if a column exists in a table.

Parameters
tableNamename of the table
columnNamecolumn name to check
Returns
true if the column already exists, false otherwise
Exceptions
TskCoreException

Definition at line 85 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), and org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback().

Referenced by org.sleuthkit.datamodel.CaseDbAccessManager.columnExists().

boolean org.sleuthkit.datamodel.CaseDbAccessManager.columnExists ( String  tableName,
String  columnName,
CaseDbTransaction  transaction 
) throws TskCoreException

Checks if a column exists in a table.

Parameters
tableNamename of the table
columnNamecolumn name to check
transactiontransaction
Returns
true if the column already exists, false otherwise
Exceptions
TskCoreException

Definition at line 117 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.CaseDbAccessManager.columnExists(), org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), and org.sleuthkit.datamodel.TskData.DbType.SQLITE.

void org.sleuthkit.datamodel.CaseDbAccessManager.createIndex ( final String  indexName,
final String  tableName,
final String  colsSQL 
) throws TskCoreException

Creates an index on the specified table, on specified column(s).

If the index already exists, it does nothing, and no error is generated.

It is recommended that clients of the API use module specific prefixes to prevent name collisions.

Parameters
indexNamename of index to create
tableNamename of table to create the index on
colsSQL- columns on which to index
Exceptions
TskCoreException

Definition at line 346 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.acquireSingleUserCaseWriteLock(), and org.sleuthkit.datamodel.SleuthkitCase.releaseSingleUserCaseWriteLock().

void org.sleuthkit.datamodel.CaseDbAccessManager.createTable ( final String  tableName,
final String  tableSchema 
) throws TskCoreException

Creates a table with the specified name and schema.

If the table already exists, it does nothing, and no error is generated

It is recommended that clients of the API use module specific prefixes to prevent name collisions.

Parameters
tableNamename of the table to create
tableSchematable schema
Exceptions
TskCoreException

Definition at line 251 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.acquireSingleUserCaseWriteLock(), and org.sleuthkit.datamodel.SleuthkitCase.releaseSingleUserCaseWriteLock().

void org.sleuthkit.datamodel.CaseDbAccessManager.delete ( final String  tableName,
final String  sql 
) throws TskCoreException

Deletes a row in the specified table.

Parameters
tableNametable from which to delete the row
sql- SQL string specifying the condition to identify the row to delete
Exceptions
TskCoreException

Definition at line 769 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.acquireSingleUserCaseWriteLock(), and org.sleuthkit.datamodel.SleuthkitCase.releaseSingleUserCaseWriteLock().

long org.sleuthkit.datamodel.CaseDbAccessManager.insert ( final String  tableName,
final String  sql 
) throws TskCoreException

Inserts a row in the specified table.

Parameters
tableName- table to insert into.
sql- SQL string specifying column values.
Returns
- rowID of the row
Exceptions
TskCoreException

Definition at line 374 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), and org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback().

long org.sleuthkit.datamodel.CaseDbAccessManager.insert ( final String  tableName,
final String  sql,
final CaseDbTransaction  transaction 
) throws TskCoreException

Inserts a row in the specified table, as part of the specified transaction. If the primary key is duplicate, it does nothing.

Note: For PostGreSQL, the caller must include the ON CONFLICT DO NOTHING clause

Caller is responsible for committing the transaction.

Parameters
tableName- table to insert into.
sql- SQL string specifying column values.
transactiontransaction in which the insert/update is done
Returns
- rowID of the row inserted
Exceptions
TskCoreException

Definition at line 410 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), and org.sleuthkit.datamodel.TskData.DbType.SQLITE.

void org.sleuthkit.datamodel.CaseDbAccessManager.insert ( CaseDbPreparedStatement  preparedStatement) throws TskCoreException

Performs a insert statement query with the given case prepared statement.

Parameters
preparedStatementThe case prepared statement.
Exceptions
TskCoreException

Definition at line 748 of file CaseDbAccessManager.java.

long org.sleuthkit.datamodel.CaseDbAccessManager.insertOrUpdate ( final String  tableName,
final String  sql 
) throws TskCoreException

Inserts a row in the specified table. If the primary key is duplicate, the existing row is updated.

Note: For PostGreSQL, the caller must include the ON CONFLICT UPDATE clause to handle duplicates

Parameters
tableName- table to insert into.
sql- SQL string specifying column values.
Returns
- rowID of the row inserted/updated
Exceptions
TskCoreException

Definition at line 457 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), and org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback().

long org.sleuthkit.datamodel.CaseDbAccessManager.insertOrUpdate ( final String  tableName,
final String  sql,
final CaseDbTransaction  transaction 
) throws TskCoreException

Inserts a row in the specified table, as part of the specified transaction. If the primary key is duplicate, the existing row is updated. Caller is responsible for committing the transaction.

Note: For PostGreSQL, the caller must include the ON CONFLICT UPDATE clause to handle duplicates

Parameters
tableName- table to insert into.
sql- SQL string specifying column values.
transactiontransaction in which the insert/update is done
Returns
- rowID of the row inserted/updated
Exceptions
TskCoreException

Definition at line 493 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), and org.sleuthkit.datamodel.TskData.DbType.SQLITE.

CaseDbPreparedStatement org.sleuthkit.datamodel.CaseDbAccessManager.prepareInsert ( String  tableName,
String  sql,
CaseDbTransaction  trans 
) throws TskCoreException

Creates a prepared statement object for the purposes of running an insert statement. The given SQL should not include the starting "INSERT INTO" or the name of the table.

For PostGreSQL, the caller must include the ON CONFLICT DO NOTHING clause

Parameters
tableNameThe name of the table being updated.
sqlThe insert statement without the starting "INSERT INTO (table name)" part.
transThe open transaction.
Returns
The prepared statement object.
Exceptions
TskCoreException

Definition at line 723 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), and org.sleuthkit.datamodel.TskData.DbType.SQLITE.

CaseDbPreparedStatement org.sleuthkit.datamodel.CaseDbAccessManager.prepareSelect ( String  sql) throws TskCoreException

Creates a prepared statement object for the purposes of running a select statement.

NOTE: Creating the CaseDbPreparedStatement opens a connection and acquires a read lock on the case database. For this reason, it is recommended to close the prepared statement as soon as it is no longer needed, through either a try-with-resources block or calling close(). Additionally, calling other methods that access or update the database should be avoided while the prepared statement is open to prevent possible deadlocks.

Parameters
sqlThe select statement without the starting select keyword.
Returns
The prepared statement object.
Exceptions
TskCoreException

Definition at line 677 of file CaseDbAccessManager.java.

CaseDbPreparedStatement org.sleuthkit.datamodel.CaseDbAccessManager.prepareUpdate ( String  tableName,
String  sql,
CaseDbTransaction  trans 
) throws TskCoreException

Creates a prepared statement object for the purposes of running an update statement. The given SQL should not include the starting "UPDATE" or the name of the table.

Parameters
tableNameThe name of the table being updated.
sqlThe insert statement without the starting "UPDATE (table name)" part.
transThe open transaction.
Returns
The prepared statement object.
Exceptions
TskCoreException

Definition at line 539 of file CaseDbAccessManager.java.

void org.sleuthkit.datamodel.CaseDbAccessManager.select ( final String  sql,
final CaseDbAccessQueryCallback  queryCallback 
) throws TskCoreException

Runs the specified SELECT query and then calls the specified callback with the result.

Parameters
sqlSQL string specifying the columns to select, tables to select from and the WHERE clause.
queryCallbackCallback object to process the result.
Exceptions
TskCoreException

Definition at line 637 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.acquireSingleUserCaseReadLock(), and org.sleuthkit.datamodel.SleuthkitCase.releaseSingleUserCaseReadLock().

void org.sleuthkit.datamodel.CaseDbAccessManager.select ( CaseDbPreparedStatement  preparedStatement,
CaseDbAccessQueryCallback  queryCallback 
) throws TskCoreException

Performs a select statement query with the given case prepared statement.

Parameters
preparedStatementThe case prepared statement.
queryCallbackThe callback to handle the result set.
Exceptions
TskCoreException

Definition at line 695 of file CaseDbAccessManager.java.

boolean org.sleuthkit.datamodel.CaseDbAccessManager.tableExists ( String  tableName) throws TskCoreException

Checks if a table exists in the case database.

Parameters
tableNamename of the table to check
Returns
true if the table already exists, false otherwise
Exceptions
TskCoreException

Definition at line 167 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), and org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback().

Referenced by org.sleuthkit.datamodel.CaseDbAccessManager.tableExists().

boolean org.sleuthkit.datamodel.CaseDbAccessManager.tableExists ( String  tableName,
CaseDbTransaction  transaction 
) throws TskCoreException

Checks if a table exists in the case database.

Parameters
tableNamename of the table to check
transactiontransaction
Returns
true if the table already exists, false otherwise
Exceptions
TskCoreException

Definition at line 198 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.getDatabaseType(), org.sleuthkit.datamodel.TskData.DbType.SQLITE, and org.sleuthkit.datamodel.CaseDbAccessManager.tableExists().

void org.sleuthkit.datamodel.CaseDbAccessManager.update ( CaseDbPreparedStatement  preparedStatement) throws TskCoreException

Performs an update statement query with the given case prepared statement.

Parameters
preparedStatementThe case prepared statement.
Exceptions
TskCoreException

Definition at line 560 of file CaseDbAccessManager.java.

Referenced by org.sleuthkit.datamodel.CaseDbAccessManager.update().

void org.sleuthkit.datamodel.CaseDbAccessManager.update ( final String  tableName,
final String  sql 
) throws TskCoreException

Updates row(s) in the specified table.

Parameters
tableName- table to insert into.
sql- SQL string specifying column values and conditions.
Exceptions
TskCoreException

Definition at line 581 of file CaseDbAccessManager.java.

References org.sleuthkit.datamodel.SleuthkitCase.beginTransaction(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.commit(), org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction.rollback(), and org.sleuthkit.datamodel.CaseDbAccessManager.update().

void org.sleuthkit.datamodel.CaseDbAccessManager.update ( final String  tableName,
final String  sql,
CaseDbTransaction  transaction 
) throws TskCoreException

Updates row(s) in the specified table, as part of the specified transaction. Caller is responsible for committing the transaction.

Parameters
tableName- table to insert into.
sql- SQL string specifying column values and conditions.
transaction- transaction under which the update is performed.
Exceptions
TskCoreException

Definition at line 609 of file CaseDbAccessManager.java.


The documentation for this class was generated from the following file:

Copyright © 2011-2021 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.