SqlService is the interface to a relational database. It is const and all state is stored as thread local variables.
See docLib::Sql.
Slots
- autoCommitSource
-
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 - closeSource
-
Void close()Close the database. A call to
closemay not actually close the database. It depends on how many timesopenhas been called for the current thread. The database will not be closed untilclosehas been called once for every time thatopenhas been called. - commitSource
-
Void commit()Commit all the changes made inside the current transaction.
- connectionSource
-
const Str connectionThe database specific string used to connect to the database.
- dialectSource
-
const Dialect dialectThe database dialect for this service.
- isAutoCommitSource
-
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 - isClosedSource
-
Bool isClosed()Test the closed state of the database.
- isServiceSource
-
override Bool isService()Overrides sys::Thread.isService
Return true.
- lastAutoKeySource
-
Int? lastAutoKey()Get the key that was generated by the last statement or null if no key was generated.
- logSource
-
static Log log := Log.get("sql")Standard log for the sql service
- makeSource
-
new make(Str? threadName := null, Str connection := "", Str? username := "", Str? password := "", Dialect? dialect := null)Make a new SqlService.
threadNameis the unique name used to identify the thread.connectionis the connection string. For java this is the jdbc url. For .Net this is the connection string.usernameis the username for the database login.passwordis the password for the database login.dialectis the database specific dialect implementation. If null, MySqlDialect is assumed.
- openSource
-
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.
openmay be called multiple times. Each timeopenis called, a counter is incremented. The database will not be closed untilclosehas been called for each call toopen. - passwordSource
-
const Str? passwordThe password used to connect to this database.
- rollbackSource
-
Void rollback()Undo any changes made inside the current transaction.
- runSource
-
override protected Obj? run()Overrides sys::Thread.run
Doc inherited from sys::Thread.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).
- sqlSource
-
Create a statement for this database.
- tableExistsSource
-
Bool tableExists(Str tableName)Does the specified table exist in the database?
- tableRowSource
-
Get a default row instance for the specified table. The result has a field for each table column.
- tablesSource
-
Str[] tables()List the tables in the database. Returns a list of the table names.
-
private Connection? threadConnection(Bool checked := true)Get the connection to this database for the current thread.
- usernameSource
-
const Str? usernameThe username used to connect to this database.