Package com.mckoi.database.jdbcserver
Class DefaultLocalBootable
- java.lang.Object
-
- com.mckoi.database.jdbcserver.DefaultLocalBootable
-
- All Implemented Interfaces:
LocalBootable
public class DefaultLocalBootable extends java.lang.Object implements LocalBootable
A bootable object that filters through to a JDBCDatabaseInterface but is thread-safe and multi-threaded. This is to be used when you have a local JDBC Client accessing a stand-alone database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDefaultLocalBootable.LocalJDBCDatabaseInterfaceA local implementation of JDBCDatabaseInterface that will dispose the parent LocalBootable object when the last open connection is disposed.
-
Field Summary
Fields Modifier and Type Field Description private booleanactiveSet to true when this interface is active.private booleanbootedSet to true if the database is booted.private intconnect_idThe connection id.private java.lang.Objectconnection_lockThe connection lock object.private DBSystemdbsysThe local DBSystem database object.private intopen_connectionsThe number of connections that are current open.
-
Constructor Summary
Constructors Constructor Description DefaultLocalBootable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DatabaseInterfaceboot(DBConfig config)Boots the local database with the given configuration.booleancheckExists(DBConfig config)Attempts to test if the database exists or not.DatabaseInterfaceconnectToJVM()Creates a new LocalDatabaseInterface that is connected to the database currently running in this VM.DatabaseInterfacecreate(java.lang.String username, java.lang.String password, DBConfig config)Creates and boots a local database with the given configuration.booleanisBooted()Returns true if a database has successfully been booted in this JVM.
-
-
-
Field Detail
-
booted
private boolean booted
Set to true if the database is booted.
-
active
private boolean active
Set to true when this interface is active.
-
dbsys
private DBSystem dbsys
The local DBSystem database object.
-
connect_id
private int connect_id
The connection id. This is incremented by 1 each time an interface connects to the local JVM.
-
open_connections
private int open_connections
The number of connections that are current open.
-
connection_lock
private java.lang.Object connection_lock
The connection lock object.
-
-
Method Detail
-
create
public DatabaseInterface create(java.lang.String username, java.lang.String password, DBConfig config) throws java.sql.SQLException
Creates and boots a local database with the given configuration. This is implemented from LocalBootable.- Specified by:
createin interfaceLocalBootable- Parameters:
config- the configuration variables.- Throws:
java.sql.SQLException
-
boot
public DatabaseInterface boot(DBConfig config) throws java.sql.SQLException
Boots the local database with the given configuration. This is implemented from LocalBootable.- Specified by:
bootin interfaceLocalBootable- Parameters:
config- the configuration variables.- Throws:
java.sql.SQLException
-
checkExists
public boolean checkExists(DBConfig config) throws java.sql.SQLException
Attempts to test if the database exists or not. Returns true if the database exists.- Specified by:
checkExistsin interfaceLocalBootable- Parameters:
config- the configuration variables.- Throws:
java.sql.SQLException
-
isBooted
public boolean isBooted() throws java.sql.SQLExceptionReturns true if a database has successfully been booted in this JVM. If a database hasn't been botted then it returns false.- Specified by:
isBootedin interfaceLocalBootable- Throws:
java.sql.SQLException
-
connectToJVM
public DatabaseInterface connectToJVM() throws java.sql.SQLException
Creates a new LocalDatabaseInterface that is connected to the database currently running in this VM. Calling this method must guarentee that either 'boot' or 'create' has been called in this VM beforehand.- Specified by:
connectToJVMin interfaceLocalBootable- Throws:
java.sql.SQLException
-
-