logo

const class

sql::SqlService

sys::Obj
  sys::Thread
    sql::SqlService

SqlService is the interface to a relational database. It is const and all state is stored as thread local variables.

See docLib::Sql.

Slots

autoCommit

Void autoCommit(Bool val)

Set the auto-commit state of this database. If true, each statement is committed as it is executed. If false, statements are grouped into transactions and committed when commit

Source

close

Void close()

Close the database. A call to close may not actually close the database. It depends on how many times open has been called for the current thread. The database will not be closed until close has been called once for every time that open has been called.

Source

commit

Void commit()

Commit all the changes made inside the current transaction.

Source

connection

const Str connection

The database specific string used to connect to the database.

Source

dialect

const Dialect dialect

The database dialect for this service.

Source

isAutoCommit

Bool isAutoCommit()

Test the auto-commit state of this database. If true, each statement is committed as it is executed. If false, statements are grouped into transactions and committed when commit

Source

isClosed

Bool isClosed()

Test the closed state of the database.

Source

isService

override Bool isService()

Return true.

Source

lastAutoKey

Int lastAutoKey()

Get the key that was generated by the last statement or null if no key was generated.

Source

log

static Log log := Log.get("sql")

Standard log for the sql service

Source

make

new make(Str threadName := null, Str connection := "", Str username := "", Str password := "", Dialect dialect := null)

Make a new SqlService.

  • threadName is the unique name used to identify the thread.
  • connection is the connection string. For java this is the jdbc url. For .Net this is the connection string.
  • username is the username for the database login.
  • password is the password for the database login.
  • dialect is the database specific dialect implementation. If null, MySqlDialect is assumed.

Source

open

SqlService open()

Open the database. This opens a connection to the database for the calling thread. A database must be open before it can be accessed. open may be called multiple times. Each time open is called, a counter is incremented. The database will not be closed until close has been called for each call to open.

Source

password

const Str password

The password used to connect to this database.

Source

rollback

Void rollback()

Undo any changes made inside the current transaction.

Source

run

override protected Obj run()

The run method implements the code to run in the thread. If a run function was specified in the constructor, then it is invoked, otherwise subclasses should override this method. Threads which wish to process their message queue must enter the main loop by calling the loop() method. The return value of this method is available to the first thread which calls the join method (the result is not required to be immutable).

Source

sql

Statement sql(Str sql)

Create a statement for this database.

Source

tableExists

Bool tableExists(Str tableName)

Does the specified table exist in the database?

Source

tableRow

Obj tableRow(Str tableName)

Get a default row instance for the specified table. The result has a field for each table column.

Source

tables

Str[] tables()

List the tables in the database. Returns a list of the table names.

Source

username

const Str username

The username used to connect to this database.

Source