edu.ucsb.nceas.dbadapter
Class AbstractDatabase

java.lang.Object
  extended byedu.ucsb.nceas.dbadapter.AbstractDatabase
Direct Known Subclasses:
OracleAdapter, PostgresqlAdapter, SqlserverAdapter

public abstract class AbstractDatabase
extends java.lang.Object

Java offers uniform database access through the use of JDBC. But many databases still use different SQL implementations and conventions. Thus this class offers extended programming interface that all subclasses should implement to gain access to different databases. To add a new database adapter class you must create a new class Adapter that extends edu.ucsb.nceas.dbadapter.AbstarctDatabase (where dbname is the name of the database or database driver you wish to add to your application). AbstarctDatabase is an abstract class, thus the subclasses need to implement the abstract methods.


Constructor Summary
AbstractDatabase()
           
 
Method Summary
static java.lang.Object createObject(java.lang.String className)
          Instantiate a class using the name of the class at runtime
abstract  java.lang.String getDateTimeFunction()
          The function name that gets the current date and time from the database server
abstract  java.lang.String getIsNULLFunction()
          The function name that is used to return non-NULL value
abstract  java.lang.String getStringDelimiter()
          The character that the specific database implementation uses to indicate string literals in SQL.
abstract  long getUniqueID(java.sql.Connection conn, java.lang.String tableName)
          Unique ID generator
static void main(java.lang.String[] args)
          the main routine used to test the dbadapter utility.
 java.lang.String toDate(java.lang.String dateString, java.lang.String format)
          MSSQL didn't support to_date function which to transfer a text string to date type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDatabase

public AbstractDatabase()
Method Detail

getUniqueID

public abstract long getUniqueID(java.sql.Connection conn,
                                 java.lang.String tableName)
                          throws java.sql.SQLException
Unique ID generator

Parameters:
conn - db connection in which the unique id was generated
tableName - the table which unique id was generate
Returns:
return the generated unique id as a long type
Throws:
java.sql.SQLException -
any SQLException that can be thrown during the db operation

getDateTimeFunction

public abstract java.lang.String getDateTimeFunction()
The function name that gets the current date and time from the database server

Returns:
return the current date and time function name

getIsNULLFunction

public abstract java.lang.String getIsNULLFunction()
The function name that is used to return non-NULL value

Returns:
return the non-NULL function name

getStringDelimiter

public abstract java.lang.String getStringDelimiter()
The character that the specific database implementation uses to indicate string literals in SQL. This will usually be a single qoute (').

Returns:
return the string delimiter

toDate

public java.lang.String toDate(java.lang.String dateString,
                               java.lang.String format)
MSSQL didn't support to_date function which to transfer a text string to date type. But Oracle and Postsql do.


createObject

public static java.lang.Object createObject(java.lang.String className)
                                     throws java.lang.Exception
Instantiate a class using the name of the class at runtime

Parameters:
className - the fully qualified name of the class to instantiate
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
the main routine used to test the dbadapter utility.



Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.