|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | 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 |
static int |
DB_MSSQLSERVER
|
static java.lang.String |
DB_NAME_MSSQLSERVER
|
static java.lang.String |
DB_NAME_ORACLE
|
static java.lang.String |
DB_NAME_SYBASE_ASA
|
static java.lang.String |
DB_NAME_SYBASE_ASE
|
static int |
DB_ORACLE
|
static int |
DB_SYBASE_ASA
|
static int |
DB_SYBASE_ASE
|
static int |
DB_UNKNOWN
|
protected static org.apache.log4j.Logger |
logger
The Log4J Category doing the logging. |
Constructor Summary | |
DBUtils()
Default Constructor |
Method Summary | |
static java.lang.String |
addFilter(java.lang.String sql,
org.enableit.db.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.StringBuffer |
addFilters(java.lang.StringBuffer sql,
java.util.List filters)
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.sql.PreparedStatement |
bindVars(java.sql.PreparedStatement ps,
java.util.List parms)
Binds a List of varables into a SQL statement. |
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 |
getDatabaseProduct(java.sql.DatabaseMetaData dmd)
Return one of the enumerated database products. |
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 |
static java.lang.Object |
populateBean(java.lang.Object bean,
java.util.Map dataRecord)
Read data from a Map containing data according to the convention in convertResultToList and populate a JavaBean object with it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger logger
Category
doing the logging.
public static final int DB_UNKNOWN
public static final int DB_SYBASE_ASA
public static final int DB_SYBASE_ASE
public static final int DB_ORACLE
public static final int DB_MSSQLSERVER
public static final java.lang.String DB_NAME_SYBASE_ASA
public static final java.lang.String DB_NAME_SYBASE_ASE
public static final java.lang.String DB_NAME_ORACLE
public static final java.lang.String DB_NAME_MSSQLSERVER
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.
DBException
public static int getNextIdUsingSQL(java.lang.String tableName) throws 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
-
DBException
public static int getNextId(java.lang.String tableName, boolean spSupported) throws 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 statements
DBException
public 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, org.enableit.db.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 filterpublic static java.lang.StringBuffer addFilters(java.lang.StringBuffer 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 filterpublic static java.lang.Object populateBean(java.lang.Object bean, java.util.Map dataRecord) throws DBException
convertResultToList
and populate a JavaBean object with it.
NB Due to a problem in the beanutils library this will not work with DynaBeans.
bean
- The JavaBean to populatedataRecord
- Map of property data to populate into JavaBean.
DBException
public static java.sql.PreparedStatement bindVars(java.sql.PreparedStatement ps, java.util.List parms) throws DBException
DBException
public static int getDatabaseProduct(java.sql.DatabaseMetaData dmd)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |