com.caucho.db
Class Database

java.lang.Object
  extended by com.caucho.db.Database

public class Database
extends java.lang.Object

Manager for a basic Java-based database.


Constructor Summary
Database()
          Creates the database.
Database(Path dir)
          Creates the database.
 
Method Summary
 void addTable(Table table)
          Adds a table.
 void close()
          Closes the database.
 TableFactory createTableFactory()
          Creates a table factory.
 void dropTable(java.lang.String name)
          Drops a table.
 void ensureMemoryCapacity(long minCapacity)
          Ensure a minimum memory size.
 BlockManager getBlockManager()
          Returns the block manager.
 DatabaseLock getDatabaseLock()
          Returns the database lock.
 Path getPath()
          Returns the path.
 Table getTable(java.lang.String name)
          Gets a table.
 void init()
          Initializes the database.
 boolean isFlushDirtyBlocksOnCommit()
           
 Query parseQuery(java.lang.String sql)
          Parses a query.
 void setFlushDirtyBlocksOnCommit(boolean isFlush)
           
 void setPath(Path dir)
          Sets the directory.
 void setRemoveOnError(boolean remove)
          Set if error tables should be removed.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Database

public Database()
Creates the database.


Database

public Database(Path dir)
Creates the database.

Method Detail

setPath

public void setPath(Path dir)
Sets the directory.


setRemoveOnError

public void setRemoveOnError(boolean remove)
Set if error tables should be removed.


setFlushDirtyBlocksOnCommit

public void setFlushDirtyBlocksOnCommit(boolean isFlush)

isFlushDirtyBlocksOnCommit

public boolean isFlushDirtyBlocksOnCommit()

ensureMemoryCapacity

public void ensureMemoryCapacity(long minCapacity)
Ensure a minimum memory size.

Parameters:
minCapacity - the minimum capacity in bytes

init

@PostConstruct
public void init()
          throws java.sql.SQLException
Initializes the database. All *.db files in the database directory are read for stored tables.

Throws:
java.sql.SQLException

getPath

public Path getPath()
Returns the path.


getBlockManager

public BlockManager getBlockManager()
Returns the block manager.


getDatabaseLock

public DatabaseLock getDatabaseLock()
Returns the database lock.


createTableFactory

public TableFactory createTableFactory()
Creates a table factory.


addTable

public void addTable(Table table)
              throws java.io.IOException
Adds a table.

Throws:
java.io.IOException

getTable

public Table getTable(java.lang.String name)
Gets a table.


dropTable

public void dropTable(java.lang.String name)
               throws java.sql.SQLException
Drops a table.

Throws:
java.sql.SQLException

parseQuery

public Query parseQuery(java.lang.String sql)
                 throws java.sql.SQLException
Parses a query.

Throws:
java.sql.SQLException

close

public void close()
Closes the database.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object