| java.lang.Object org.lateralnz.common.util.DAOUtils
DAOUtils | public class DAOUtils implements Constants(Code) | | utility functions for use with Data Access Objects and for more general
JDBC stuff
author: J R Briggs |
Method Summary | |
final public static String | buildSQL(ResourceBundle sqlstatements, String[] keys) | public static boolean | close(Statement st) | public static boolean | close(ResultSet rs) | public static boolean | close(Connection conn) | public static boolean | commit(Connection conn) | final public static String | createParameterPlaceholders(int count) | final public static String | createSQLArrayString(String[] vals, int start, int len) | public static String | dump(ResultSet rs) | public static String | dumpData(ResultSet rs) | public static boolean | getCharAsBoolean(ResultSet rs, String column, boolean defaultValue) get a char(1) as a boolean value. | public static ColumnMetaData | getColumnMetaData(Connection conn, String schema, String table, String column) return column meta data for a particular column using the specified connection. | public static Connection | getConnection(String datasource) | public static Date | getDate(ResultSet rs, String columnName) | public static boolean | hasColumnMetaData(String schema, String table, String column) a method for checking if column meta data has been cached for the specified schema, table
and column name. | public static boolean | isDuplicateKeyException(Throwable t) | public static boolean | isDuplicateKeyException(SQLException se) | final public static String | parseInClause(String sql, int numInList) | final public static void | registerDriver(String driverClass) | public static void | setParam(PreparedStatement ps, int col, String value) set a String parameter on a prepared statement according to its index. | public static void | setParam(PreparedStatement ps, int col, int value) set an int parameter on a prepared statement according to its index.
Note: if the value is less than 0, setNull will be called. | public static void | setParam(PreparedStatement ps, int col, int value, boolean preserve) set an int parameter on a prepared statement according to its index. | public static void | setParam(PreparedStatement ps, int col, float value) set a float parameter on a prepared statement according to its index. | public static void | setParam(PreparedStatement ps, int col, Date value) set a Date parameter on a prepared statement according to its index. | public static void | setParam(PreparedStatement ps, int col, boolean value) |
createParameterPlaceholders | final public static String createParameterPlaceholders(int count)(Code) | | |
createSQLArrayString | final public static String createSQLArrayString(String[] vals, int start, int len)(Code) | | |
getCharAsBoolean | public static boolean getCharAsBoolean(ResultSet rs, String column, boolean defaultValue) throws SQLException(Code) | | get a char(1) as a boolean value. e.g. Y = true, N = false, an empty char = defaultvalue
|
getColumnMetaData | public static ColumnMetaData getColumnMetaData(Connection conn, String schema, String table, String column) throws SQLException(Code) | | return column meta data for a particular column using the specified connection. If the data
is present in the cache, then the cached metadata is returned, otherwise the connection is used
and the response is cached.
|
getConnection | public static Connection getConnection(String datasource) throws SQLException(Code) | | get a connection from a named datasource using JNDI
Parameters: datasource - the name of the data source to retrieve |
getDate | public static Date getDate(ResultSet rs, String columnName) throws SQLException(Code) | | given a resultset and column name of a timestamp column,
return the column as a java.util.Date
|
hasColumnMetaData | public static boolean hasColumnMetaData(String schema, String table, String column)(Code) | | a method for checking if column meta data has been cached for the specified schema, table
and column name.
BEWARE: this method may need to change from database to database
|
isDuplicateKeyException | public static boolean isDuplicateKeyException(Throwable t)(Code) | | |
isDuplicateKeyException | public static boolean isDuplicateKeyException(SQLException se)(Code) | | |
setParam | public static void setParam(PreparedStatement ps, int col, String value) throws SQLException(Code) | | set a String parameter on a prepared statement according to its index.
Note: if the value is null, this will call setNull
Parameters: ps - the PreparedStatement Parameters: col - the index of the parameter Parameters: value - the string to set |
setParam | public static void setParam(PreparedStatement ps, int col, int value) throws SQLException(Code) | | set an int parameter on a prepared statement according to its index.
Note: if the value is less than 0, setNull will be called. If you
want to set a negative integer, then you must call setParam with
preserveNegative set to true.
Parameters: ps - the PreparedStatement Parameters: col - the index of the parameter Parameters: value - the int value to set |
setParam | public static void setParam(PreparedStatement ps, int col, int value, boolean preserve) throws SQLException(Code) | | set an int parameter on a prepared statement according to its index.
Note: if the value is less than 0, setNull will be called unless
preserve is set to true
Parameters: ps - the PreparedStatement Parameters: col - the index of the parameter Parameters: value - the int value to set Parameters: preserveNegative - do not call setNull if this is true |
setParam | public static void setParam(PreparedStatement ps, int col, float value) throws SQLException(Code) | | set a float parameter on a prepared statement according to its index.
Note: if the value is Float.NEGATIVE_INFINITY, setNull will be called
Parameters: ps - the PreparedStatement Parameters: col - the index of the parameter Parameters: value - the float value to set Parameters: preserveNegative - do not call setNull if this is true |
setParam | public static void setParam(PreparedStatement ps, int col, Date value) throws SQLException(Code) | | set a Date parameter on a prepared statement according to its index.
Note: if the value is null, this will call setNull
Parameters: ps - the PreparedStatement Parameters: col - the index of the parameter Parameters: value - the date to set |
|
|