org.opensha.refFaultParamDb.dao.db
Class PrioritizedDB_Access

java.lang.Object
  extended by org.opensha.refFaultParamDb.dao.db.PrioritizedDB_Access
All Implemented Interfaces:
DB_AccessAPI

public class PrioritizedDB_Access
extends Object
implements DB_AccessAPI

This class represents a list of DB_AccessAPI's. The first one that works will be used for all connections. This is ideal for the case where you would prefer a direct DB connection, but it might be blocked by a firewall, in which case you fall back to a servlet brokered connection.

Author:
kevin

Field Summary
 
Fields inherited from interface org.opensha.refFaultParamDb.dao.db.DB_AccessAPI
INSERT_UPDATE_QUERY, INSERT_UPDATE_SPATIAL, RESET_PASSWORD, SELECT_QUERY, SELECT_QUERY_SPATIAL, SEQUENCE_NUMBER
 
Constructor Summary
PrioritizedDB_Access(ArrayList<DB_AccessAPI> accessors)
           
 
Method Summary
static ArrayList<DB_AccessAPI> createDB2ReadOnlyAccessors()
           
static ArrayList<DB_AccessAPI> createDB3ReadOnlyAccessors()
           
 void destroy()
           
 void destroy(int millis)
           
 int getNextSequenceNumber(String sequenceName)
          Gets the next unique sequence number to be insertd in the table.
 String getSystemDate()
          Get the sytem date from oracle database
 int[] insertUpdateOrDeleteBatch(ArrayList<String> sqls, boolean rollbackOnFail)
          Executes a batch of sql statements.
 int insertUpdateOrDeleteData(String sql)
          Insert/Update/Delete record in the database.
 int insertUpdateOrDeleteData(String sql, ArrayList<oracle.spatial.geometry.JGeometry> geometryList)
          Insert/Update/Delete record in the database.
static boolean isAccessorValid(DB_AccessAPI dbAccess)
           
static void main(String[] args)
           
 CachedRowSet queryData(String sql)
          Query the databse and returns the Results in a CachedRowset object.
 SpatialQueryResult queryData(String sqlWithSpatialColumnNames, String sqlWithNoSpatialColumnNames, ArrayList<String> spatialColumnNames)
          Query the databse and returns the Results in a object which contains CachedRowSet as well as JGeomtery objects.
 int resetPasswordByEmail(String email)
          Reset the password in the database for the provided email address
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrioritizedDB_Access

public PrioritizedDB_Access(ArrayList<DB_AccessAPI> accessors)
Method Detail

createDB2ReadOnlyAccessors

public static ArrayList<DB_AccessAPI> createDB2ReadOnlyAccessors()

createDB3ReadOnlyAccessors

public static ArrayList<DB_AccessAPI> createDB3ReadOnlyAccessors()

isAccessorValid

public static boolean isAccessorValid(DB_AccessAPI dbAccess)

getNextSequenceNumber

public int getNextSequenceNumber(String sequenceName)
                          throws SQLException
Description copied from interface: DB_AccessAPI
Gets the next unique sequence number to be insertd in the table.

Specified by:
getNextSequenceNumber in interface DB_AccessAPI
Parameters:
sequenceName - String
Returns:
int
Throws:
SQLException

getSystemDate

public String getSystemDate()
                     throws SQLException
Description copied from interface: DB_AccessAPI
Get the sytem date from oracle database

Specified by:
getSystemDate in interface DB_AccessAPI
Returns:
Throws:
SQLException

insertUpdateOrDeleteData

public int insertUpdateOrDeleteData(String sql)
                             throws SQLException
Description copied from interface: DB_AccessAPI
Insert/Update/Delete record in the database.

Specified by:
insertUpdateOrDeleteData in interface DB_AccessAPI
Parameters:
sql - String
Returns:
int
Throws:
SQLException

insertUpdateOrDeleteBatch

public int[] insertUpdateOrDeleteBatch(ArrayList<String> sqls,
                                       boolean rollbackOnFail)
                                throws SQLException
Description copied from interface: DB_AccessAPI
Executes a batch of sql statements. if any fail, then you can optionally roll back any changes if rollbackOnFail is true.

Specified by:
insertUpdateOrDeleteBatch in interface DB_AccessAPI
Returns:
array of update counts, or null if update failed
Throws:
SQLException

insertUpdateOrDeleteData

public int insertUpdateOrDeleteData(String sql,
                                    ArrayList<oracle.spatial.geometry.JGeometry> geometryList)
                             throws SQLException
Description copied from interface: DB_AccessAPI
Insert/Update/Delete record in the database. This method should be used when one of the columns in the database is a spatial column

Specified by:
insertUpdateOrDeleteData in interface DB_AccessAPI
Parameters:
sql - String
Returns:
int
Throws:
SQLException

queryData

public CachedRowSet queryData(String sql)
                       throws SQLException
Description copied from interface: DB_AccessAPI
Query the databse and returns the Results in a CachedRowset object.

Specified by:
queryData in interface DB_AccessAPI
Parameters:
sql - String
Returns:
CachedRowSet
Throws:
SQLException

queryData

public SpatialQueryResult queryData(String sqlWithSpatialColumnNames,
                                    String sqlWithNoSpatialColumnNames,
                                    ArrayList<String> spatialColumnNames)
                             throws SQLException
Description copied from interface: DB_AccessAPI
Query the databse and returns the Results in a object which contains CachedRowSet as well as JGeomtery objects.

Specified by:
queryData in interface DB_AccessAPI
Returns:
CachedRowSet
Throws:
SQLException

resetPasswordByEmail

public int resetPasswordByEmail(String email)
                         throws SQLException
Description copied from interface: DB_AccessAPI
Reset the password in the database for the provided email address

Specified by:
resetPasswordByEmail in interface DB_AccessAPI
Returns:
Throws:
SQLException

main

public static void main(String[] args)

destroy

public void destroy()
             throws SQLException
Specified by:
destroy in interface DB_AccessAPI
Throws:
SQLException

destroy

public void destroy(int millis)
             throws SQLException
Specified by:
destroy in interface DB_AccessAPI
Throws:
SQLException