Overview | File | Class | Tree | Index | Help
| Jala 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class jala.db.RamDatabase

    Object
       |
       +--jala.db.RamDatabase

Direct Known Subclasses:
  jala.db.FileDatabase

class jala.db.RamDatabase

Instances of this class represent an in-memory sql database.
Important: You need the h2.jar in directory "lib/ext" of your helma installation for this library to work, which you can get at http://www.h2database.com/.
Defined in Database.js

Constructor Summary
`jala.db.RamDatabase (<String> name, <String> username, <String> password)` Returns a newly created RamDatabase instance.

Method Summary
`void` | `copyTables(<helma.Database> database, <Array> tables)` Copies all tables in the database passed as argument into this embedded database.
`Boolean` | `dropTable(<String> tableName)` Drops the table with the given name
`Boolean` | `dump(<helma.File> file, <Object> props)` Dumps the database schema and data into a file
`helma.Database` | `getConnection(props)` Returns a connection to this database
`String` | `getName()` Returns the name of the database
`String` | `getPassword()` Returns the password of this database
`helma.util.ResourceProperties` | `getProperties(<Object> props)` Returns a properties object containing the connection properties for this database.
`String` | `getUrl(<Object> props)` Returns the JDBC Url to connect to this database
`String` | `getUsername()` Returns the username of this database
`Boolean` | `runScript(<helma.File> file, <Object> props, <String> charset, <Boolean> continueOnError)` Runs the script file passed as argument in the context of this database.
`void` | `shutdown()` Stops this in-process database by issueing a "SHUTDOWN" sql command.
`Boolean` | `tableExists(<String> name)` Returns true if the table exists already in the database

Constructor Detail

### jala.db.RamDatabase

    jala.db.RamDatabase(<String> name, <String> username, <String> password)

Returns a newly created RamDatabase instance.

Parameters:

`name` - The name of the database. If not given a private un-named database is created, that can only be accessed through this instance of jala.db.RamDatabase

`username` - Optional username (defaults to "sa"). This username is used when creating the database, so the same should be used when creating subsequent instances of jala.db.RamDatabase pointing to a named database.

`password` - Optional password (defaults to "").

Returns:

A newly created instance of RamDatabase

Method Detail

### copyTables

    void copyTables(<helma.Database> database, <Array> tables)

Copies all tables in the database passed as argument into this embedded database. If any of the tables already exists in this database, they will be removed before re-created. Please mind that this method ignores any indexes in the source database, but respects the primary key settings.

Parameters:

`database` - The database to copy the tables from

`tables` - An optional array containing the names of the tables to copy. If not given all tables are copied

### dropTable

    Boolean dropTable(<String> tableName)

Drops the table with the given name

Parameters:

`tableName` - The name of the table

Returns:

True if the table was successfully dropped, false otherwise

### dump

    Boolean dump(<helma.File> file, <Object> props)

Dumps the database schema and data into a file

Parameters:

`file` - The file where the database dump will be

`props` - Optional object containing connection properties

Returns:

True in case the database was successfully dumped, false otherwise

### getConnection

    helma.Database getConnection(props)

Returns a connection to this database

Parameters:

`An` - optional parameter object containing connection properties to add to the connection Url.

Returns:

A connection to this database

### getName

    String getName()

Returns the name of the database

Returns:

The name of the database

### getPassword

    String getPassword()

Returns the password of this database

Returns:

The password of this database

### getProperties

    helma.util.ResourceProperties getProperties(<Object> props)

Returns a properties object containing the connection properties for this database.

Parameters:

`props` - An optional parameter object containing connection properties to add to the connection Url.

Returns:

A properties object containing the connection properties

### getUrl

    String getUrl(<Object> props)

Returns the JDBC Url to connect to this database

Parameters:

`props` - Optional connection properties to add

Returns:

The JDBC url to use for connecting to this database

### getUsername

    String getUsername()

Returns the username of this database

Returns:

The username of this database

### runScript

    Boolean runScript(<helma.File> file, <Object> props, <String> charset, <Boolean> continueOnError)

Runs the script file passed as argument in the context of this database. Use this method to eg. create and/or populate a database.

Parameters:

`file` - The script file to run

`props` - Optional object containing connection properties

`charset` - Optional character set to use (defaults to "UTF-8")

`continueOnError` - Optional flag indicating whether to continue on error or not (defaults to false)

Returns:

True in case the script was executed successfully, false otherwise

### shutdown

    void shutdown()

Stops this in-process database by issueing a "SHUTDOWN" sql command.

### tableExists

    Boolean tableExists(<String> name)

Returns true if the table exists already in the database

Parameters:

`name` - The name of the table

Returns:

True if the table exists, false otherwise

Overview | File | Class | Tree | Index | Help
| Jala 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008