23 namespace Deveel.Data.Protocol {
33 this.controller = controller;
34 this.databaseName = databaseName;
65 public IDatabaseInterface
Create(
string username,
string password, IDbConfig config) {
66 if (String.IsNullOrEmpty(username) ||
67 String.IsNullOrEmpty(password))
68 throw new DataException(
"Username and Password must both be set.");
71 throw new DataException(
"Database is already created.");
78 dbsys = controller.CreateDatabase(config, databaseName, username, password);
89 return (dbsys == null ? null : dbsys.Database);
93 public IDatabaseInterface
Boot(IDbConfig config) {
95 throw new DataException(
"Database was booted more than once.");
102 if (controller.IsInitialized(databaseName))
103 dbsys = controller.ConnectToDatabase(config, databaseName);
105 dbsys = controller.StartDatabase(config, databaseName);
118 throw new DataException(
"The database is already booted.");
120 return controller.DatabaseExists(config, databaseName);
124 public bool IsBooted {
125 get {
return booted; }
131 throw new DataException(
"The database is not started.");
158 : base(localBootable, localBootable.databaseName, hostString) {
159 this.localBootable = localBootable;
164 protected override void Dispose(
bool disposing) {
169 --localBootable.openConnections;
172 if (localBootable.openConnections <= 0) {
175 localBootable.dbsys.Close();
176 localBootable.booted =
false;
177 localBootable.dbsys = null;
LocalDatabaseInterface(DefaultLocalBootable localBootable, string hostString)
IDatabaseInterface Boot(IDbConfig config)
bool booted
Set to true if the database is booted.
bool CheckExists(IDbConfig config)
readonly DefaultLocalBootable localBootable
The representation of a single database in the system.
Control.DbSystem dbsys
The local DbSystem database object.
int openConnections
The number of connections that are current open.
readonly DbController controller
override void Dispose(bool disposing)
IDatabaseInterface Connect()
IDatabase GetDatabase(string databaseName)
DefaultLocalBootable(DbController controller, string databaseName)
int connectId
The connection id.
A local implementation of DatabaseInterface that will dispose the parent ILocalBootable object when t...
IDatabaseInterface Create(string username, string password, IDbConfig config)
readonly string databaseName
A bootable object that filters through to a DatabaseInterface but is thread-safe and multi-threaded...