DSRG.MW
Class DBManager

java.lang.Object
  |
  +--DSRG.MW.DBManager
Direct Known Subclasses:
DBMAccess, DBMOracle

public abstract class DBManager
extends java.lang.Object

The lowest layer of the DB connection, right above the ODBC driver.
All methods go directly to the DB, every time they are invoked.
This is subclassed to provide functionality for different DB systems in the ISs.


Field Summary
 java.lang.String className
          The Class name for the appropriate DB driver
protected  boolean connected
          am I connected?
 java.sql.Connection connection
          the DB connection
static java.lang.String date_datatype
          constant for the string Oracle expects for the date datatype
(package private) static boolean DEBUG
           
 java.lang.Class driver
          the DB driver
 java.lang.String ISName
          the name of the IS for this DBManager
static java.lang.String numeric_datatype
          constant for the string Oracle expects for the numeric datatype
 java.lang.String passwd
          Password
 java.lang.String url
          DB URL
 java.lang.String user
          Username
 
Constructor Summary
DBManager()
          constructior.
Initializes the "connected" variable.
 
Method Summary
abstract  boolean addAttribute(java.lang.String RelationName, java.lang.String AttributeName, java.lang.String type, int size)
           
abstract  boolean addRelation(java.lang.String relationName, java.util.Vector attName, java.util.Vector attTypes)
          interface for the schema change operations
abstract  boolean deleteAttribute(java.lang.String RelationName, java.lang.String attributeName)
           
abstract  boolean deleteRelation(java.lang.String name, boolean silent)
           
 Table executeQuery(java.lang.String SQL)
          executes a SQL-Query against one database.
 Table executeViewQuery(java.lang.String SQL)
          executes a SQL-View-Query against one database (which should be the local database, of course).
 java.util.Vector getAttributeExtent(java.lang.String RelationName, java.lang.String AttributeName)
          returns a vector of strings, which represent actual data values.
 java.util.Vector getAttributeNames(java.lang.String RelationName)
          returns a vector of strings representing attribute names in a certain relation
10/6/97 koeller
 java.lang.String getAttributeType(java.lang.String relationName, java.lang.String attributeName)
          a string representing the type (in the syntax of the underlying DB!) of the attribute attributeName in the relation relationName
10/6/97 koeller
 java.lang.String getISName()
          returns the ISName for this DBManager
 java.util.Vector getRelationNames()
          gets Relation names for this IS.
private  java.lang.String getTableName(java.lang.String SQL, int index)
          determines which table a certain attribute comes from.
 boolean isConnected()
          am I connected?
(package private)  java.lang.String makeSelectClause(java.lang.String schema)
          Helper function.
private  Table privateExecuteQuery(java.lang.String SQL, boolean withRelationNames)
          returns a single Table object not tied to an IS.
abstract  boolean renameAttribute(java.lang.String RelationName, java.lang.String oldName, java.lang.String newName)
           
 java.lang.String renameAttributeInSchema(java.lang.String schema, java.lang.String oldName, java.lang.String newName)
          Helper function.
abstract  boolean renameRelation(java.lang.String oldName, java.lang.String newName)
           
 boolean sendUpdate(java.lang.String relationName, int count, java.lang.String update)
          send an update :)
abstract  boolean storeRelation(Table table)
           
 java.lang.String stripAttributeFromSchema(java.lang.String schema, java.lang.String attributeName)
          Helper function.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEBUG

static final boolean DEBUG

url

public java.lang.String url
DB URL

user

public java.lang.String user
Username

passwd

public java.lang.String passwd
Password

className

public java.lang.String className
The Class name for the appropriate DB driver

driver

public java.lang.Class driver
the DB driver

connection

public java.sql.Connection connection
the DB connection

ISName

public java.lang.String ISName
the name of the IS for this DBManager

connected

protected boolean connected
am I connected?

numeric_datatype

public static final java.lang.String numeric_datatype
constant for the string Oracle expects for the numeric datatype

date_datatype

public static final java.lang.String date_datatype
constant for the string Oracle expects for the date datatype
Constructor Detail

DBManager

public DBManager()
constructior.
Initializes the "connected" variable.
Method Detail

isConnected

public boolean isConnected()
am I connected?

getISName

public java.lang.String getISName()
returns the ISName for this DBManager

getRelationNames

public java.util.Vector getRelationNames()
gets Relation names for this IS.
10/6/97 koeller

getAttributeNames

public java.util.Vector getAttributeNames(java.lang.String RelationName)
returns a vector of strings representing attribute names in a certain relation
10/6/97 koeller

getAttributeType

public java.lang.String getAttributeType(java.lang.String relationName,
                                         java.lang.String attributeName)
a string representing the type (in the syntax of the underlying DB!) of the attribute attributeName in the relation relationName
10/6/97 koeller

getAttributeExtent

public java.util.Vector getAttributeExtent(java.lang.String RelationName,
                                           java.lang.String AttributeName)
returns a vector of strings, which represent actual data values. (regardless of their type in the DB there are always strings coming back!)
10/6/97 koeller

executeQuery

public Table executeQuery(java.lang.String SQL)
executes a SQL-Query against one database. The attribute names in the returning table are composed of relation names and attribute names of the attributes in the select-clause.

executeViewQuery

public Table executeViewQuery(java.lang.String SQL)
executes a SQL-View-Query against one database (which should be the local database, of course). The attribute names in the returning table are only the attribute names of the attributes in the select-clause. Otherwise, this method is equivalent to
See Also:
executeQuery(String SQL)

privateExecuteQuery

private Table privateExecuteQuery(java.lang.String SQL,
                                  boolean withRelationNames)
returns a single Table object not tied to an IS.
expects SQL in the dialect the DB understands, so for now we need to stick with basic SQL (which we do in the theory...).
If the second parameter is true, the Table object contains attribute names that are composed of relation and attribute names of the SQL-Query in the oaramater. Otherwise, the attribute names are only attribute names, and do not contain relation names. This method should only be called by the executeQuery() and executeViewQuery()-methods.

sendUpdate

public boolean sendUpdate(java.lang.String relationName,
                          int count,
                          java.lang.String update)
send an update :)

addRelation

public abstract boolean addRelation(java.lang.String relationName,
                                    java.util.Vector attName,
                                    java.util.Vector attTypes)
interface for the schema change operations

deleteRelation

public abstract boolean deleteRelation(java.lang.String name,
                                       boolean silent)

renameAttribute

public abstract boolean renameAttribute(java.lang.String RelationName,
                                        java.lang.String oldName,
                                        java.lang.String newName)

addAttribute

public abstract boolean addAttribute(java.lang.String RelationName,
                                     java.lang.String AttributeName,
                                     java.lang.String type,
                                     int size)

deleteAttribute

public abstract boolean deleteAttribute(java.lang.String RelationName,
                                        java.lang.String attributeName)

renameRelation

public abstract boolean renameRelation(java.lang.String oldName,
                                       java.lang.String newName)

storeRelation

public abstract boolean storeRelation(Table table)

stripAttributeFromSchema

public java.lang.String stripAttributeFromSchema(java.lang.String schema,
                                                 java.lang.String attributeName)
Helper function.
this strips one attribute from a schema obtained by getSchema(), kind of awkward...

getTableName

private java.lang.String getTableName(java.lang.String SQL,
                                      int index)
determines which table a certain attribute comes from.
looks like this function (ResultSetMetaData.getTableName(int i)) is not implemented in the JDBC driver, so I have to parse the table name from the SQL-String. Great!!!!
it's only partly implemented - it needs:
{<table_name>.<attribute_name>,}<table_name>.<attribute_name> as a format.
It also doesn't work when there is a "*" in the select clause 6/3/98 koeller I'm going to have to fix the *-Problem, but it's only working with one relation then 9/24/98 koeller

renameAttributeInSchema

public java.lang.String renameAttributeInSchema(java.lang.String schema,
                                                java.lang.String oldName,
                                                java.lang.String newName)
Helper function.
this renames one attribute in a schema obtained by getSchema(),

makeSelectClause

java.lang.String makeSelectClause(java.lang.String schema)
Helper function.
This turns a schema obtained by getSchema into a list of attribute names without the types, to include them in a select clause when copying tables