com.partnersoft.sql
Class EmbeddedDatabase

java.lang.Object
  extended by com.partnersoft.sql.EmbeddedDatabase

public class EmbeddedDatabase
extends java.lang.Object

An embedded (no server process, local filesystem) SQL database. Includes methods for creating, deleting, and connecting to it.

Currently the engine used is Hypersonic SQL (HSQLDB). This may change in the future, so shouldn't be depended on.

Copyright 2006 Partner Softare, Inc.

Author:
Paul Reavis

Constructor Summary
EmbeddedDatabase(Path path)
          Creates a new embedded database for the given path.
EmbeddedDatabase(java.lang.String pathDescription)
          Creates a new embedded database for the given path description.
 
Method Summary
 void close()
          Closes the database connection and database.
 SqlConnection getConnection()
          Returns the database connection to the database.
 Path getPath()
          Returns the path to the database.
 boolean isOpen()
          Returns true if the database is open (connected).
 void open()
          Opens the database for reading and writing.
 void openReadOnly()
          Opens the database for reading only.
 void openReadWrite()
          Opens the database for reading and writing.
 void remove()
          Removes the database, including all data and all associated files.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmbeddedDatabase

public EmbeddedDatabase(java.lang.String pathDescription)
Creates a new embedded database for the given path description.


EmbeddedDatabase

public EmbeddedDatabase(Path path)
Creates a new embedded database for the given path.

Method Detail

open

public void open()
          throws java.sql.SQLException
Opens the database for reading and writing.

Throws:
java.sql.SQLException

openReadWrite

public void openReadWrite()
                   throws java.sql.SQLException
Opens the database for reading and writing.

Throws:
java.sql.SQLException

openReadOnly

public void openReadOnly()
                  throws java.sql.SQLException
Opens the database for reading only.

Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Closes the database connection and database.

Throws:
java.sql.SQLException

remove

public void remove()
            throws java.sql.SQLException,
                   java.io.IOException
Removes the database, including all data and all associated files.

Throws:
java.sql.SQLException
java.io.IOException

getConnection

public SqlConnection getConnection()
Returns the database connection to the database. Returns null if the database has not been opened via open().


getPath

public Path getPath()
Returns the path to the database.


isOpen

public boolean isOpen()
Returns true if the database is open (connected).

Returns:
true if database is open

toString

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