jetweb is hosted by Hepforge, IPPP Durham

cedar.jetweb.db
Class DBObjectManager

java.lang.Object
  extended by cedar.jetweb.db.DBObjectManager

public class DBObjectManager
extends java.lang.Object

Class for reading and writing objects from a database. uses the names of the objects' methods to determine what should be written and read, e.g get** is written to the db, set** is read from the db

Author:
J.Monk

Constructor Summary
DBObjectManager()
           
 
Method Summary
 int fillObject(java.lang.Object obj, java.sql.ResultSet dbrs)
          Fills the object obj from the database resultset dbrs
 DBConnectionManager getDBConnection()
          Return the DBConnectionManager that is being used Shouldn't write itself to the DB unless there is a column called DBConnection, in which case it might try!
 DBObjectManager passDBConnection(DBConnectionManager theDataBase)
          Pass the DBConnectionManager to be used for accessing the database(s)
 void writeObject(java.lang.Object obj, java.lang.String tableName, java.lang.String dbName)
          writes an Object obj to the database with the given name
 java.lang.Object writeToDB(java.lang.String dbName)
          Writes this object to a table of the same name as the object in the specified database
 java.lang.Object writeToDB(java.lang.String tableName, java.lang.String dbName)
          Writes this object to the table with the given name in the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBObjectManager

public DBObjectManager()
Method Detail

passDBConnection

public DBObjectManager passDBConnection(DBConnectionManager theDataBase)
Pass the DBConnectionManager to be used for accessing the database(s)

Parameters:
DBConnectionManager - the connectionManager that contains the connection to the database we want


getDBConnection

public DBConnectionManager getDBConnection()
Return the DBConnectionManager that is being used Shouldn't write itself to the DB unless there is a column called DBConnection, in which case it might try!


fillObject

public int fillObject(java.lang.Object obj,
                      java.sql.ResultSet dbrs)
               throws java.sql.SQLException
Fills the object obj from the database resultset dbrs

Returns:
int the number of parameters filled
Throws:
java.sql.SQLException


writeObject

public void writeObject(java.lang.Object obj,
                        java.lang.String tableName,
                        java.lang.String dbName)
                 throws JetWebException
writes an Object obj to the database with the given name

Parameters:
obj - the object to be written
tableName - the name of the table in the database to write to
dbName - the name of the database to use, as managed by the DBConnectionManager
Throws:
JetWebException


writeToDB

public java.lang.Object writeToDB(java.lang.String tableName,
                                  java.lang.String dbName)
                           throws JetWebException
Writes this object to the table with the given name in the database

Parameters:
tableName - the name of the table to write this object to
dbName - the name (as managed by the DBConnectionManager) of the database to use
Throws:
JetWebException


writeToDB

public java.lang.Object writeToDB(java.lang.String dbName)
                           throws JetWebException
Writes this object to a table of the same name as the object in the specified database

Parameters:
dbName - the name (as managed by the DBConnectionManager) of the database to use
Throws:
JetWebException