|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.joanju.cg.db.DB
public class DB
Core database access.
Most of this class's methods are synchronized for thread-safety.
General access to the database is done through thread-local LocalConnection objects, which are acquired through localConnection().
For the embedded database, we use JDBC directly. If the user has a Hibernate config file, then we use Hibernate and their connection settings.
Field Summary | |
---|---|
protected static java.sql.Connection |
connection
|
protected java.sql.SQLException |
connectionException
|
protected static DB |
instance
|
protected java.lang.ThreadLocal<com.joanju.cg.db.LocalConnection> |
localConnections
|
Constructor Summary | |
---|---|
protected |
DB()
|
Method Summary | |
---|---|
protected static void |
clear()
Drop and reload the tables. |
protected void |
dropTables()
|
protected static java.lang.String |
generateDBName()
|
static java.sql.Connection |
getThreadLocalConnection()
Get this thread's Connection TO BE USED FOR READ-ONLY QUERIES ONLY. |
protected static DB |
instance()
We use a Singleton, because the existance of the instance of this object gives us a promise that the database has been loaded sucessfully, and that it has the schema and startup data loaded. |
protected void |
loadDatabase()
|
protected static void |
loadWrapper()
|
static java.sql.Connection |
newConnection()
Create a new connection, for reports and such that have to create temp tables. |
java.lang.String |
schemaString()
This is only used in my unit tests. |
static void |
shutdown()
|
static void |
touch()
Touch the database, just to keep the db connection alive. |
protected void |
update(java.lang.String expression)
Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement. |
protected void |
writeMeta()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.sql.SQLException connectionException
protected static java.sql.Connection connection
protected static DB instance
protected java.lang.ThreadLocal<com.joanju.cg.db.LocalConnection> localConnections
Constructor Detail |
---|
protected DB()
Method Detail |
---|
protected static DB instance() throws java.sql.SQLException
java.io.IOException
java.sql.SQLException
protected static void clear() throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
protected void dropTables() throws java.sql.SQLException
java.sql.SQLException
protected static java.lang.String generateDBName()
public static java.sql.Connection getThreadLocalConnection() throws java.sql.SQLException
java.sql.SQLException
protected void loadDatabase() throws java.sql.SQLException
java.sql.SQLException
protected static void loadWrapper() throws java.sql.SQLException
java.sql.SQLException
public static java.sql.Connection newConnection() throws java.sql.SQLException
java.sql.SQLException
public java.lang.String schemaString() throws java.sql.SQLException
java.sql.SQLException
public static void shutdown() throws java.sql.SQLException
java.sql.SQLException
public static void touch() throws java.sql.SQLException
java.sql.SQLException
protected void update(java.lang.String expression) throws java.sql.SQLException
java.sql.SQLException
protected void writeMeta() throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |