| java.lang.Object de.danet.an.util.JDBCUtil
JDBCUtil | public class JDBCUtil (Code) | | Collection of JDBC utilities.
This class adds common utilitites for a JDBC environment.
|
Inner Class :final public static class DBProperties implements Serializable | |
Method Summary | |
public static void | closeAll(ResultSet rs, Statement st, Connection con) Close a connection, a prepared statement or a statement and a
result set, if allocated, i.e. | public static DBProperties | dbProperties(DataSource dataSource) Return the database properties for the given data source and
connection. | public static DBProperties | dbProperties(DataSource dataSource, Connection con) Return the database properties for the given data source and
connection. | public static Object | getBinary(ResultSet rs, int offset) Retrieves the byte array from the ResultSet, create an object
and returns it.
Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet an Object. | public static Integer | getInteger(ResultSet rs, int offset) Retrieves the Integer from the ResultSet, create an object
and returns it.
Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet an Integer or null . | public static Long | getLong(ResultSet rs, int offset) Retrieves the Long from the ResultSet, create an object
and returns it.
Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet a Long or null . | public static String | getString(DataSource dataSource, ResultSet rs, int offset) Retrieves a string from the result set. | public static int | getTableColumnSize(Connection dbConnection, String tableName, String columnName, int defaultValue) Retrieves the defined size of a table column by using
the database meta schema.
Parameters: dbConnection - the connection to be used for requesting the meta schema Parameters: tableName - the table name where the column is located Parameters: columnName - the name of the column for the request Parameters: defaultValue - if the database driver delivers an illegallength (0) for a varchar type column, this value is returned. | public static DataSource | refreshDS(DataSource dsToTest, String dbName) Refresh the Data Source of the database. |
closeAll | public static void closeAll(ResultSet rs, Statement st, Connection con) throws SQLException(Code) | | Close a connection, a prepared statement or a statement and a
result set, if allocated, i.e. if != null.
Parameters: rs - a result set or null. Parameters: st - a prepared statement, statement or null Parameters: con - a connection or null. throws: SQLException - if a sql error occurs. |
dbProperties | public static DBProperties dbProperties(DataSource dataSource) throws SQLException(Code) | | Return the database properties for the given data source and
connection.
Parameters: dataSource - the data source the database properties throws: SQLException - if an error occurs while obtaining therequired information |
dbProperties | public static DBProperties dbProperties(DataSource dataSource, Connection con) throws SQLException(Code) | | Return the database properties for the given data source and
connection.
Parameters: dataSource - the data source Parameters: con - the connection the database properties throws: SQLException - if an error occurs while obtaining therequired information |
getInteger | public static Integer getInteger(ResultSet rs, int offset) throws SQLException(Code) | | Retrieves the Integer from the ResultSet, create an object
and returns it.
Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet an Integer or null . throws: SQLException - if a sql error occurs. |
getLong | public static Long getLong(ResultSet rs, int offset) throws SQLException(Code) | | Retrieves the Long from the ResultSet, create an object
and returns it.
Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet a Long or null . throws: SQLException - if a sql error occurs. |
getString | public static String getString(DataSource dataSource, ResultSet rs, int offset) throws IOException, SQLException(Code) | | Retrieves a string from the result set. For drivers that are
known not to support getString for all string
lengths, getCharacterStream will be used. This
method should be used instead of
ResultSet.getString if the field is of type
LONGVARCHAR .
Parameters: dataSource - the data soure that had been used to obtainthe connection. Parameters: rs - a result set. Parameters: offset - an int offset for the ResultSet the String or null . throws: IOException - any of the usual Input/Output related exceptions. throws: SQLException - if a sql error occurs. |
getTableColumnSize | public static int getTableColumnSize(Connection dbConnection, String tableName, String columnName, int defaultValue) throws SQLException(Code) | | Retrieves the defined size of a table column by using
the database meta schema.
Parameters: dbConnection - the connection to be used for requesting the meta schema Parameters: tableName - the table name where the column is located Parameters: columnName - the name of the column for the request Parameters: defaultValue - if the database driver delivers an illegallength (0) for a varchar type column, this value is returned. the column size. throws: SQLException - if a database error occurs. |
refreshDS | public static DataSource refreshDS(DataSource dsToTest, String dbName) throws NamingException(Code) | | Refresh the Data Source of the database.
Parameters: dsToTest - Data source to test Parameters: dbName - jndi name of the database the data source throws: NamingException - if the resource is not present. |
|
|