|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enableit.db.DBUtils
Provides utilities to be used in conjunction with the database proxies.
DatabaseProxy
,
GenericDBProxy
Field Summary | |
static java.lang.String |
about
Information on the exact CVS version accessible after compilation |
protected static org.apache.log4j.Category |
cat
The Log4J Category doing the logging. |
private static java.lang.String |
PROC_GET_NEXT_ID
Name of stored procedure used for getNextId |
private static java.lang.String |
SQL_GET_NEXT_ID
Dynamic SQL used for getNextId |
private static java.lang.String |
SQL_INIT_ID
Dynamic SQL used for getNextId, initialises the table if no previous query |
private static java.lang.String |
SQL_SET_NEXT_ID
Dynamic SQL used for getNextIdUsingSQL to update the id to the next one |
Constructor Summary | |
DBUtils()
Default Constructor |
Method Summary | |
static java.lang.String |
addFilter(java.lang.String sql,
DBFilter filter)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value |
static java.lang.String |
addFilter(java.lang.String sql,
java.lang.String filterCol,
java.lang.String filterVal)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value |
static java.lang.String |
addFilters(java.lang.String sql,
java.util.List filters)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value |
static java.util.ArrayList |
convertHashMapToArrayList(java.util.HashMap attributes)
Converts a set of name-value pairs stored in a java.util.HashMap
to values only stored in a java.util.ArrayList |
static java.util.ArrayList |
convertHashtableToArrayList(java.util.Hashtable attributes)
Converts a set of name-value pairs stored in a java.util.Hashtable
to values only stored in a java.util.ArrayList |
static java.util.List |
convertResultToList(java.sql.ResultSet sqlResults)
Turns a ResultSet into an ArrayList
of TreeMaps |
static int |
getNextId(java.lang.String tableName,
boolean spSupported)
Returns the next available id for the specified table |
static int |
getNextIdUsingSQL(java.lang.String tableName)
Returns the next available id for the specified table |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static org.apache.log4j.Category cat
Category
doing the logging.
Same Category
is used throughout the package.private static final java.lang.String PROC_GET_NEXT_ID
private static final java.lang.String SQL_SET_NEXT_ID
private static final java.lang.String SQL_GET_NEXT_ID
private static final java.lang.String SQL_INIT_ID
public static final java.lang.String about
Constructor Detail |
public DBUtils()
Method Detail |
public static java.util.ArrayList convertHashtableToArrayList(java.util.Hashtable attributes)
java.util.Hashtable
to values only stored in a java.util.ArrayList
public static java.util.ArrayList convertHashMapToArrayList(java.util.HashMap attributes)
java.util.HashMap
to values only stored in a java.util.ArrayList
public static java.util.List convertResultToList(java.sql.ResultSet sqlResults) throws DBException
ResultSet
into an ArrayList
of TreeMaps
ArrayList
of TreeMap
s. Each
map contains the column heading value pairs for a single result set
row.public static int getNextIdUsingSQL(java.lang.String tableName) throws java.rmi.RemoteException, DBException
Returns the next available id for the specified table
The implementation makes use of a number fountain in the database to avoid the chance of two EJB onstances attempting to use the same key
tableName
- public static int getNextId(java.lang.String tableName, boolean spSupported) throws java.rmi.RemoteException, DBException
Returns the next available id for the specified table
The implementation makes use of a number fountain in the database to avoid the chance of two EJB onstances attempting to use the same key
tableName
- spSupported
- true - if stored procedures are to be used to execute the queries
false - to use dynamic SQL statementspublic static java.lang.String addFilter(java.lang.String sql, java.lang.String filterCol, java.lang.String filterVal)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value
If filterCol and / or filterVal are null then no filter is added. This could be modified to allow joins to null values, but presents issues of what datatype to send to the database
sql
- The base query to which we wish to add a filterfilterCol
- The column to filter onfilterVal
- The value to filter onpublic static java.lang.String addFilter(java.lang.String sql, DBFilter filter)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value
If filter name and / or filter value are null then no filter is added. This could be modified to allow joins to null values, but presents issues of what datatype to send to the database
sql
- The base query to which we wish to add a filterfilter
- All the encapsulated filter datapublic static java.lang.String addFilters(java.lang.String sql, java.util.List filters)
Adds a 'where' or 'and' clause as appropriate to join on the supplied column and value
If filter name and / or filter value are null then no filter is added. This could be modified to allow joins to null values, but presents issues of what datatype to send to the database
sql
- The base query to which we wish to add a filterfilter
- A java.util.List of DBFilter objects containing the encapsulated filter data
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |