|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.experiment.DatabaseUtils
DatabaseUtils provides utility functions for accessing the experiment database. The jdbc driver and database to be used default to "jdbc.idbDriver" and "jdbc:idb=experiments.prp". These may be changed by creating a java properties file called DatabaseUtils.props in user.home or the current directory. eg:
jdbcDriver=jdbc.idbDriver
jdbcURL=jdbc:idb=experiments.prp
Field Summary | |
static int |
BOOL
|
static int |
BYTE
|
static int |
DATE
|
static int |
DOUBLE
|
static java.lang.String |
EXP_INDEX_TABLE
The name of the table containing the index to experiments |
static java.lang.String |
EXP_RESULT_COL
The name of the column containing the results table name |
static java.lang.String |
EXP_RESULT_PREFIX
The prefix for result table names |
static java.lang.String |
EXP_SETUP_COL
The name of the column containing the experiment setup (parameters) |
static java.lang.String |
EXP_TYPE_COL
The name of the column containing the experiment type (ResultProducer) |
static int |
FLOAT
|
static int |
INTEGER
|
static int |
LONG
|
static int |
SHORT
|
static int |
STRING
|
Constructor Summary | |
DatabaseUtils()
Sets up the database drivers |
Method Summary | |
static java.lang.String |
arrayToString(java.lang.Object[] array)
Converts an array of objects to a string by inserting a space between each element. |
void |
connectToDatabase()
Opens a connection to the database |
void |
createExperimentIndex()
Attempts to create the experiment index table |
java.lang.String |
createExperimentIndexEntry(ResultProducer rp)
Attempts to insert a results entry for the table into the experiment index. |
java.lang.String |
createResultsTable(ResultProducer rp,
java.lang.String tableName)
Creates a results table for the supplied result producer. |
java.lang.String |
databaseURLTipText()
Returns the tip text for this property |
void |
disconnectFromDatabase()
Closes the connection to the database. |
boolean |
execute(java.lang.String query)
Executes a SQL query. |
boolean |
experimentIndexExists()
Returns true if the experiment index exists. |
java.lang.String |
getDatabaseURL()
Get the value of DatabaseURL. |
java.lang.String |
getPassword()
Get the database password |
java.lang.Object[] |
getResultFromTable(java.lang.String tableName,
ResultProducer rp,
java.lang.Object[] key)
Executes a database query to extract a result for the supplied key from the database. |
java.sql.ResultSet |
getResultSet()
Gets the results generated by a previous query. |
java.lang.String |
getResultsTableName(ResultProducer rp)
Gets the name of the experiment table that stores results from a particular ResultProducer. |
java.lang.String |
getUsername()
Get the database username |
boolean |
isConnected()
Returns true if a database connection is active. |
void |
putResultInTable(java.lang.String tableName,
ResultProducer rp,
java.lang.Object[] key,
java.lang.Object[] result)
Executes a database query to insert a result for the supplied key into the database. |
void |
setDatabaseURL(java.lang.String newDatabaseURL)
Set the value of DatabaseURL. |
void |
setPassword(java.lang.String password)
Set the database password |
void |
setUsername(java.lang.String username)
Set the database username |
boolean |
tableExists(java.lang.String tableName)
Checks that a given table exists. |
static java.lang.String |
typeName(int type)
Returns the name associated with a SQL type. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String EXP_INDEX_TABLE
public static final java.lang.String EXP_TYPE_COL
public static final java.lang.String EXP_SETUP_COL
public static final java.lang.String EXP_RESULT_COL
public static final java.lang.String EXP_RESULT_PREFIX
public static final int STRING
public static final int BOOL
public static final int DOUBLE
public static final int BYTE
public static final int SHORT
public static final int INTEGER
public static final int LONG
public static final int FLOAT
public static final int DATE
Constructor Detail |
public DatabaseUtils() throws java.lang.Exception
java.lang.Exception
- if an error occursMethod Detail |
public void setUsername(java.lang.String username)
username
- Username for Database.public java.lang.String getUsername()
public void setPassword(java.lang.String password)
password
- Password for Database.public java.lang.String getPassword()
public static java.lang.String arrayToString(java.lang.Object[] array)
array
- the array of objects
public static java.lang.String typeName(int type)
type
- the SQL type
public java.lang.String databaseURLTipText()
public java.lang.String getDatabaseURL()
public void setDatabaseURL(java.lang.String newDatabaseURL)
newDatabaseURL
- Value to assign to DatabaseURL.public void connectToDatabase() throws java.lang.Exception
java.lang.Exception
- if an error occurspublic void disconnectFromDatabase() throws java.lang.Exception
java.lang.Exception
- if an error occurspublic boolean isConnected()
public boolean execute(java.lang.String query) throws java.sql.SQLException
query
- the SQL query
java.sql.SQLException
- if an error occurspublic java.sql.ResultSet getResultSet() throws java.sql.SQLException
java.sql.SQLException
- if an error occurspublic boolean tableExists(java.lang.String tableName) throws java.lang.Exception
tableName
- the name of the table to look for.
java.lang.Exception
- if an error occurs.public java.lang.Object[] getResultFromTable(java.lang.String tableName, ResultProducer rp, java.lang.Object[] key) throws java.lang.Exception
tableName
- the name of the table where the result is storedrp
- the ResultProducer who will generate the result if requiredkey
- the key for the result
java.lang.Exception
- if an error occurspublic void putResultInTable(java.lang.String tableName, ResultProducer rp, java.lang.Object[] key, java.lang.Object[] result) throws java.lang.Exception
tableName
- the name of the table where the result is storedrp
- the ResultProducer who will generate the result if requiredkey
- the key for the resultresult
- the result to store
java.lang.Exception
- if an error occurspublic boolean experimentIndexExists() throws java.lang.Exception
java.lang.Exception
- if an error occurspublic void createExperimentIndex() throws java.lang.Exception
java.lang.Exception
- if an error occurs.public java.lang.String createExperimentIndexEntry(ResultProducer rp) throws java.lang.Exception
rp
- the ResultProducer generating the results
java.lang.Exception
- if an error occurs.public java.lang.String getResultsTableName(ResultProducer rp) throws java.lang.Exception
rp
- the ResultProducer
java.lang.Exception
- if an error occurspublic java.lang.String createResultsTable(ResultProducer rp, java.lang.String tableName) throws java.lang.Exception
rp
- the ResultProducer generating the resultstableName
- the name of the resultsTable
java.lang.Exception
- if an error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London