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 class
DefaultLocalBootable.LocalJDBCDatabaseInterface
A 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 boolean
active
Set to true when this interface is active.private boolean
booted
Set to true if the database is booted.private int
connect_id
The connection id.private java.lang.Object
connection_lock
The connection lock object.private DBSystem
dbsys
The local DBSystem database object.private int
open_connections
The 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 DatabaseInterface
boot(DBConfig config)
Boots the local database with the given configuration.boolean
checkExists(DBConfig config)
Attempts to test if the database exists or not.DatabaseInterface
connectToJVM()
Creates a new LocalDatabaseInterface that is connected to the database currently running in this VM.DatabaseInterface
create(java.lang.String username, java.lang.String password, DBConfig config)
Creates and boots a local database with the given configuration.boolean
isBooted()
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:
create
in 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:
boot
in 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:
checkExists
in interfaceLocalBootable
- Parameters:
config
- the configuration variables.- Throws:
java.sql.SQLException
-
isBooted
public boolean isBooted() throws java.sql.SQLException
Returns true if a database has successfully been booted in this JVM. If a database hasn't been botted then it returns false.- Specified by:
isBooted
in 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:
connectToJVM
in interfaceLocalBootable
- Throws:
java.sql.SQLException
-
-