| 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjas.statistics.db.Database
public class Database
A Database object represents a connection with a database management system (natively to a HSQLDB one). It is able to generate creation scripts and to manage multi run data storage.
Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
| Constructor Summary | |
|---|---|
Database(java.lang.String dbPath,
         java.lang.String dbName,
         boolean appendRows)
Create a new database object using the HSQL database driver.  | 
|
Database(java.lang.String dbDriver,
         java.lang.String fullConnectionString,
         java.lang.String dbName,
         java.lang.String userName,
         java.lang.String pwd)
Create a new database object using the specified database driver.  | 
|
| Method Summary | |
|---|---|
 CollectionTable | 
addCollectionTable(java.lang.String name,
                   java.util.Collection collection)
Create a new CollectionTable object, using the specified collection, and append it to the table list.  | 
 CollectionTable | 
addCollectionTable(java.lang.String name,
                   int pkMode,
                   java.util.Collection collection)
Create a new CollectionTable object, using the specified collection, and append it to the table list.  | 
 Table | 
addTable(java.lang.String name)
Create a new Table object and append it to the table list.  | 
 Table | 
addTable(java.lang.String name,
         int pkMode)
Create a new Table object and append it to the table list.  | 
 boolean | 
addTable(Table table)
Add a table object to the table list and synchronize it with this database manager.  | 
 void | 
dropDatabaseTables()
This method drops the tables currently in the list of tables added with the addTable methods.  | 
 int | 
execute(java.lang.String expression)
Execute a SQL command on the database.  | 
 java.sql.Connection | 
getConnection()
Return the current connection to the database.  | 
 int | 
getRunId()
Return the current number.  | 
 Table | 
getTable(java.lang.String name)
Return a table with the given name.  | 
 java.util.ArrayList | 
getTableCachedDataOnDatabase(java.lang.String tableName)
 | 
 java.util.Collection | 
getTables()
Return the collection of tables added to the database manager.  | 
 void | 
openDatabase()
Open the database according to the opening mode specified in the Database constructor.  | 
 void | 
performAction(int actionType)
The object implementing this interface is able to receive an event notify.  | 
 java.sql.ResultSet | 
query(java.lang.String expression)
Execute a SQL query command on the database and returns a result set.  | 
 void | 
update()
Update all the tables.  | 
| Methods inherited from class java.lang.Object | 
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public Database(java.lang.String dbPath,
                java.lang.String dbName,
                boolean appendRows)
         throws java.sql.SQLException
dbPath - The absolute path to the database files on disk.dbName - The name of the database file.appendRows - False causes the database to be created from scratch. If true the Database 
                                                                                object tries to synch the existing database (if it is not existing it creates a new one)
                                                                                and appends the record to the existing tables.
java.sql.SQLException - If something goes wrong with the database connection
public Database(java.lang.String dbDriver,
                java.lang.String fullConnectionString,
                java.lang.String dbName,
                java.lang.String userName,
                java.lang.String pwd)
         throws java.sql.SQLException
dbDriver - The fully qualified name of the java class representing the JDBC driver to be used.fullConnectionString - The absolute connection string to access the database.dbName - The name of the database.userName - The login name to access the database.pwd - The password for the user name.
java.sql.SQLException - If something goes wrong with the database connection| Method Detail | 
|---|
public CollectionTable addCollectionTable(java.lang.String name,
                                          java.util.Collection collection)
name - The name of the table. It must be unique in the database table list.collection - A Java collection of agents from whose the table collects data.
public CollectionTable addCollectionTable(java.lang.String name,
                                          int pkMode,
                                          java.util.Collection collection)
name - The name of the table. It must be unique in the database table list.collection - A Java collection of agents from whose the table collects data.
public Table addTable(java.lang.String name)
name - The name of the table. It must be unique in the database table list.
public Table addTable(java.lang.String name,
                      int pkMode)
name - The name of the table. It must be unique in the database table list.
public boolean addTable(Table table)
table - A Table object.
public void dropDatabaseTables()
                        throws java.sql.SQLException
java.sql.SQLException - If something goes wrong executing the script
public int execute(java.lang.String expression)
            throws java.sql.SQLException
expression - A SQL script to be executed.
java.sql.SQLException - If something goes wrong executing the scriptpublic java.sql.Connection getConnection()
public int getRunId()
public Table getTable(java.lang.String name)
name - The name of the table to be found.
public java.util.ArrayList getTableCachedDataOnDatabase(java.lang.String tableName)
public java.util.Collection getTables()
public void openDatabase()
                  throws java.sql.SQLException
java.sql.SQLException - If something goes wrong creating or synching the databasepublic void performAction(int actionType)
ISimEventListener
performAction in interface ISimEventListeneractionType - The switch id to select the right action to perform. It
  might be an Sim.EVENT_* or a custom defined constant.
public java.sql.ResultSet query(java.lang.String expression)
                         throws java.sql.SQLException
expression - A SQL query script.
java.sql.SQLException - If something goes wrong executing the scriptpublic void update()
  | 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||