proper.database
Class Executor

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.database.ConnectorObject
          extended by proper.database.Executor
All Implemented Interfaces:
ProperInterface

public class Executor
extends ConnectorObject

This class executes SQL-Statements (try-catch-wrapper to avoid long code).

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
Executor(Connector conn)
          initializes the object
 
Method Summary
 int count(java.lang.String sql)
          returns the number of columns this statement will return, -1 if it does not succeed
 int getDistinctCount(java.lang.String table, java.lang.String column)
          returns the number of distinct records in a table for a given column, returns -1 if not successful
 int getDistinctCount(java.lang.String table, java.util.Vector columns)
          returns the number of distinct records in a table for the given columns, returns -1 if not successful
 java.util.Vector getDistinctValues(java.lang.String table, java.lang.String column)
          returns the distinct values in a table for a given column
 java.util.Vector getDistinctValues(java.lang.String table, java.lang.String column, boolean classified)
          returns the distinct values in a table for a given column, we can can restrict to classified rows, i.e.
 java.lang.Exception getLastException()
          returns the last Exception (can be null)
 java.lang.String getLastStatement()
          returns the last SQL statement
 int getRecordCount(java.lang.String table)
          returns the number of records in a table, returns -1 if not successful
 int getRecordCount(java.lang.String table, java.lang.String column, boolean classified)
          returns the number of records in a table, returns -1 if not successful
 java.sql.ResultSet select(java.lang.String sql)
          executes the given SELECT-statement and returns the result-set
 boolean update(java.lang.String sql)
          executes the given SQL-statement (INSERT, UDPATE or DELETE) and returns whether it succeeded
 
Methods inherited from class proper.database.ConnectorObject
getConnector
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Executor

public Executor(Connector conn)
initializes the object

Parameters:
conn - the Connector to use for accessing the DB
Method Detail

select

public java.sql.ResultSet select(java.lang.String sql)
executes the given SELECT-statement and returns the result-set

Returns:
the corresponding ResultSet, can be null if statement fails

update

public boolean update(java.lang.String sql)
executes the given SQL-statement (INSERT, UDPATE or DELETE) and returns whether it succeeded

Returns:
the corresponding ResultSet, can be null if statement fails

count

public int count(java.lang.String sql)
returns the number of columns this statement will return, -1 if it does not succeed


getRecordCount

public int getRecordCount(java.lang.String table)
returns the number of records in a table, returns -1 if not successful


getRecordCount

public int getRecordCount(java.lang.String table,
                          java.lang.String column,
                          boolean classified)
returns the number of records in a table, returns -1 if not successful

Parameters:
table - the table to count the rows
column - the column to check for classified or unclassified instances, if "" it is ignored
classified - whether to check for classified or unclassified instances, is ignored if column == ""

getDistinctCount

public int getDistinctCount(java.lang.String table,
                            java.lang.String column)
returns the number of distinct records in a table for a given column, returns -1 if not successful


getDistinctCount

public int getDistinctCount(java.lang.String table,
                            java.util.Vector columns)
returns the number of distinct records in a table for the given columns, returns -1 if not successful


getDistinctValues

public java.util.Vector getDistinctValues(java.lang.String table,
                                          java.lang.String column)
returns the distinct values in a table for a given column


getDistinctValues

public java.util.Vector getDistinctValues(java.lang.String table,
                                          java.lang.String column,
                                          boolean classified)
returns the distinct values in a table for a given column, we can can restrict to classified rows, i.e. column is not NULL, otherwise all, i.e. NULL can be included


getLastException

public java.lang.Exception getLastException()
returns the last Exception (can be null)


getLastStatement

public java.lang.String getLastStatement()
returns the last SQL statement