Class ThreadSafeDatabase
-
Constructor Summary
ConstructorsConstructorDescriptionWraps the given database with a threadsafe version -
Method Summary
Modifier and TypeMethodDescriptionvoidStarts a transactionvoidclose()Closes the databasevoidCommits current transactionvoidExecute an update query.voidExecute an update query with params.voidExecute an update query with params.executeQuery(String sql) This method should be called with SELECT type statements that return row set.executeQuery(String sql, Object... params) This method should be called with SELECT type statements that return row set it accepts object with params.executeQuery(String sql, String[] params) This method should be called with SELECT type statements that return row set.Returns the underlying easy thread we can use to pipe tasks to the db threadvoidRolls back current transactionMethods inherited from class Database
delete, exists, getDatabasePath, isCustomPathSupported, openOrCreate, supportsWasNull, wasNullModifier and TypeMethodDescriptionstatic voidDeletes databasestatic booleanIndicates weather a database existsstatic StringgetDatabasePath(String databaseName) Returns the file path of the Database if exists and if supported on the platform.static booleanChecks if this platform supports custom database paths.static DatabaseopenOrCreate(String databaseName) Opens a database or create one if not exists.static booleansupportsWasNull(Row row) Checks to see if the given row supports#wasNull(com.codename1.db.Row).static booleanChecks if the last value accessed from a given row was null.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
ThreadSafeDatabase
Wraps the given database with a threadsafe version
Parameters
db: the database
-
-
Method Details
-
getThread
Returns the underlying easy thread we can use to pipe tasks to the db thread
Returns
the easy thread object
-
beginTransaction
Description copied from class:DatabaseStarts a transaction
NOTE: Not supported in Javascript port. This method will do nothing when running in Javascript.
Throws
IOException: if database is not opened
- Specified by:
beginTransactionin classDatabase- Throws:
IOException
-
commitTransaction
Description copied from class:DatabaseCommits current transaction
NOTE: Not supported in Javascript port. This method will do nothing when running in Javascript.
Throws
IOException: if database is not opened or transaction was not started
- Specified by:
commitTransactionin classDatabase- Throws:
IOException
-
rollbackTransaction
Description copied from class:DatabaseRolls back current transaction
NOTE: Not supported in Javascript port. This method will do nothing when running in Javascript.
Throws
IOException: if database is not opened or transaction was not started
- Specified by:
rollbackTransactionin classDatabase- Throws:
IOException
-
close
-
execute
Description copied from class:DatabaseExecute an update query. Used for INSERT, UPDATE, DELETE and similar sql statements.
Parameters
sql: the sql to execute
Throws
IOException
- Specified by:
executein classDatabase- Throws:
IOException
-
execute
Description copied from class:DatabaseExecute an update query with params. Used for INSERT, UPDATE, DELETE and similar sql statements. The sql can be constructed with '?' and the params will be binded to the query
Parameters
-
sql: the sql to execute -
params: to bind to the query where the '?' exists
Throws
IOException
- Specified by:
executein classDatabase- Throws:
IOException
-
-
executeQuery
Description copied from class:DatabaseThis method should be called with SELECT type statements that return row set.
Parameters
-
sql: the sql to execute -
params: to bind to the query where the '?' exists
Returns
a cursor to iterate over the results
Throws
IOException
- Specified by:
executeQueryin classDatabase- Throws:
IOException
-
-
executeQuery
Description copied from class:DatabaseThis method should be called with SELECT type statements that return row set.
Parameters
sql: the sql to execute
Returns
a cursor to iterate over the results
Throws
IOException
- Specified by:
executeQueryin classDatabase- Throws:
IOException
-
executeQuery
Description copied from class:DatabaseThis method should be called with SELECT type statements that return row set it accepts object with params.
Parameters
-
sql: the sql to execute -
params: @param params to bind to the query where the '?' exists, supported object types are String, byte[], Double, Long and null
Returns
a cursor to iterate over the results
Throws
IOException
- Overrides:
executeQueryin classDatabase- Throws:
IOException
-
-
execute
Description copied from class:DatabaseExecute an update query with params. Used for INSERT, UPDATE, DELETE and similar sql statements. The sql can be constructed with '?' and the params will be binded to the query
Parameters
-
sql: the sql to execute -
params: @param params to bind to the query where the '?' exists, supported object types are String, byte[], Double, Long and null
Throws
IOException
- Overrides:
executein classDatabase- Throws:
IOException
-
-