com.adventnet.services.database
Class DatabaseHandler

java.lang.Object
  |
  +--com.adventnet.services.database.DatabaseHandler

class DatabaseHandler
extends java.lang.Object

This class handles the Database queries through the JDBCHandler


Inner Class Summary
(package private)  class DatabaseHandler.JDBCHandlerExt
           
 
Field Summary
(package private)  boolean cacheFlag
           
(package private)  int[] columnAccess
           
(package private)  java.util.Hashtable columnMap
           
(package private)  java.lang.String[] columnNames
           
(package private)  java.lang.String[] columnTypes
           
(package private)  java.lang.String databaseURL
           
(package private)  DBCacher dbCacher
           
(package private)  int debugLevel
           
(package private)  java.lang.String driverName
           
(package private)  java.lang.String[] indexNames
           
(package private)  com.adventnet.utilities.db.JDBCHandler jdbc
           
(package private)  java.lang.String passwd
           
(package private)  java.lang.String tableName
           
(package private)  java.lang.String userName
           
 
Constructor Summary
(package private) DatabaseHandler()
          NoArg Constructor.
 
Method Summary
 void addRow(java.lang.Object[] indexObjects, CompositeData entry)
          When the manager is trying to add a row in the database table, this method can be called.
 boolean connect(DatabaseAdaptor adaptor)
           
 void deleteRow(java.lang.Object[] indexObjects)
          When the manager is trying to delete a row in the table, this method can be called.
 java.util.ArrayList getEntries(int startIndex, int endIndex)
          This method gives an ArrayList of the CompositeData instances in this table starting from the startIndex through till the EndIndex.
 CompositeData getEntry(java.lang.Object[] indexObjects, boolean requestFromCacher)
          This method is used to get the entry from the database.
 CompositeData getFirstEntry()
          To get the first entry in the table from the database.
 CompositeData getNextEntry(java.lang.Object[] indexObjects, boolean requestFromCacher)
          To get the next entry for the given row (identified by the instance)
 TabularData getTabularDataFromDB(java.lang.String query)
          Using this method we are able to get the TabularData from the database
 void initDBColumnNames()
          This method is used to get the database column names.
 void initDBIndexNames()
          This method is used to get the database index names.
 void modifyRow(java.lang.Object[] indexObjects, CompositeData entry)
          When the manager is trying to modify a row in the database table, this method can be called.
 int totalRows()
          This method gives the total number of rows in the table present in the database.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

databaseURL

java.lang.String databaseURL

userName

java.lang.String userName

passwd

java.lang.String passwd

tableName

java.lang.String tableName

driverName

java.lang.String driverName

columnNames

java.lang.String[] columnNames

indexNames

java.lang.String[] indexNames

columnTypes

java.lang.String[] columnTypes

columnAccess

int[] columnAccess

columnMap

java.util.Hashtable columnMap

debugLevel

int debugLevel

cacheFlag

boolean cacheFlag

dbCacher

DBCacher dbCacher

jdbc

com.adventnet.utilities.db.JDBCHandler jdbc
Constructor Detail

DatabaseHandler

DatabaseHandler()
NoArg Constructor.
Method Detail

connect

public boolean connect(DatabaseAdaptor adaptor)

initDBColumnNames

public void initDBColumnNames()
This method is used to get the database column names.

initDBIndexNames

public void initDBIndexNames()
This method is used to get the database index names.

getFirstEntry

public CompositeData getFirstEntry()
To get the first entry in the table from the database.
Returns:
instance of javax.jmx.openmbean.CompositeData with the entry information. Otherwise null.

getNextEntry

public CompositeData getNextEntry(java.lang.Object[] indexObjects,
                                  boolean requestFromCacher)
To get the next entry for the given row (identified by the instance)
Parameters:
indexObjects - the object array with index objects which identifies the row
requestFromCacher - Specifies whether this request comes from DBCacher and functions accordingly.
Returns:
instance of javax.jmx.openmbean.CompositeData with the entry information. Otherwise null.

getEntry

public CompositeData getEntry(java.lang.Object[] indexObjects,
                              boolean requestFromCacher)
This method is used to get the entry from the database.
Parameters:
The - indexes which identifies the row as an Object Array.
requestFromCacher - Specifies whether this request comes from DBCacher and functions accordingly.
Returns:
The entry as a CompositeData

totalRows

public int totalRows()
This method gives the total number of rows in the table present in the database.
Returns:
int specifying the number of rows in the Table.

getEntries

public java.util.ArrayList getEntries(int startIndex,
                                      int endIndex)
This method gives an ArrayList of the CompositeData instances in this table starting from the startIndex through till the EndIndex. For example: If the 1st 5 rows have to be retrieved, then the start index will be 1 and the end index will be 5.
Returns:
ArrayList of the instances of the CompositeData.

addRow

public void addRow(java.lang.Object[] indexObjects,
                   CompositeData entry)
            throws java.lang.Exception
When the manager is trying to add a row in the database table, this method can be called.
Parameters:
indexObjects - the object array with index objects which identifies the row to be added.
entry - the entry value as javax.jmx.openmbean.CompositeData instance.

modifyRow

public void modifyRow(java.lang.Object[] indexObjects,
                      CompositeData entry)
               throws java.lang.Exception
When the manager is trying to modify a row in the database table, this method can be called.
Parameters:
indexObjects - the object array with index objects which identifies the row to be modified.
entry - the entry value as javax.jmx.openmbean.CompositeData instance.

deleteRow

public void deleteRow(java.lang.Object[] indexObjects)
               throws java.lang.Exception
When the manager is trying to delete a row in the table, this method can be called.
Parameters:
indexObjects - the object array with index objects which identifies the row to be deleted.
entry - the entry value as javax.jmx.openmbean.CompositeData instance.

getTabularDataFromDB

public TabularData getTabularDataFromDB(java.lang.String query)
                                 throws java.io.IOException,
                                        java.sql.SQLException,
                                        java.lang.Exception
Using this method we are able to get the TabularData from the database
Parameters:
query -  
Returns:
TabularData