| java.lang.Object com.nabhinc.util.db.DBUtil
DBUtil | public class DBUtil (Code) | | Provides utility methods to get a database connection. Depending on
availability of JTA, the connection is either a pooled connection from
a data source, or a direct connection to a database.
author: Padmanabh Dabke author: (c) 2001 Nabh Information Systems, Inc. All Rights Reserved. |
Constructor Summary | |
public | DBUtil() Do nothing constructor. |
Method Summary | |
public static boolean | beginTransaction() Starts a transaction only if it has not been started. | public static boolean | checkRelation(String dsName, String sql) | public static boolean | checkRelation(DataSource ds, String sql) | public static void | close(Connection con) | public static void | close(ResultSet rs) | public static void | close(java.sql.Statement st) | public static void | commitTransaction() Invokes commit on transaction manager. | public static HashMap | constructEnumMap(DataSource ds, String sql) | public static boolean | execute(String dsName, String sql, Object[] params) | public static boolean | execute(DataSource ds, String sql, Object[] params) | public static boolean | execute(String dsName, String sql) | public static boolean | execute(DataSource ds, String sql) | public static java.sql.Connection | getConnection() Gets a datbase connection. | public static Connection | getConnection(String dsName) Gets a datbase connection from a datasource that is looked up
using the given JNDI. | public static int | getCount(String dsName, String sql, Object[] params) Assumes that the specified SQL query returns a number. | public static int | getCount(DataSource ds, String sql, Object[] params) Assumes that the specified SQL query returns a number. | public static DataSource | getDataSource(String dsName) Gets a datbase connection from a datasource that is looked up
using the given JNDI. | public static String | getDataSourceFlavor(String dsName) | public static java.sql.Date | getDateField(String dsName, String sql) | public static java.sql.Date | getDateField(DataSource ds, String sql) | public static String | getField(String dsName, String sql, int sqlType, String format) | public static String | getField(DataSource ds, String sql, int sqlType, String format) | public static String | getField(String dsName, String sql, int sqlType, String format, Locale locale) | public static String | getField(DataSource ds, String sql, int sqlType, String format, Locale locale) | public static String | getField(String dsName, String sql) | public static String | getField(DataSource ds, String sql) | public static Vector | getFields(String dsName, String sql, int sqlType, String format) | public static Vector | getFields(DataSource ds, String sql, int sqlType, String format) | public static String | getFormattedValue(ResultSet rs, int colIndex, int colType, String format) | public static String | getFormattedValue(ResultSet rs, int colIndex, int colType, String format, Locale locale) | public static Connection | getJDBCConnection(String dsName) | public static String[] | getRecord(String dsName, String sql, int[] sqlTypes, String[] formats) | public static String[] | getRecord(String dsName, String sql, int[] sqlTypes, String[] formats, Object[] params) | public static String[] | getRecord(DataSource ds, String sql, int[] sqlTypes, String[] formats, Object[] params) | public static String[] | getRecord(String dsName, String sql) | public static String[] | getRecord(DataSource ds, String sql) | public static Vector | getRecords(String dsName, String sql, int[] sqlTypes, String[] formats) | public static Vector | getRecords(DataSource ds, String sql, int[] sqlTypes, String[] formats) | public static Vector | getRecords(String dsName, String sql) | public static Vector | getRecords(DataSource ds, String sql) | public static Vector | getRecordsHelper(Connection conn, String sql, int[] sqlTypes, String[] formats) | public static int | getStatus() | public static void | rollbackTransaction() Rolls back current transaction. | public static void | setRollbackOnly() Mark current transaction for rollback. |
dbuDSFlavorsTable | protected static Hashtable<String, String> dbuDSFlavorsTable(Code) | | Maintains mapping between datasource names and flavor strings.
|
dbuLocalDSTable | public static Hashtable<String, DataSource> dbuLocalDSTable(Code) | | Hashtable used to keep the mapping between datasource names and
datasource implementations.
|
dbuUseJNDI | public static boolean dbuUseJNDI(Code) | | |
DBUtil | public DBUtil()(Code) | | Do nothing constructor.
|
beginTransaction | public static boolean beginTransaction() throws Exception(Code) | | Starts a transaction only if it has not been started.
true if a new transaction was started exception: java.sql.SQLException - Database exception. |
getCount | public static int getCount(String dsName, String sql, Object[] params) throws SQLException, NamingException(Code) | | Assumes that the specified SQL query returns a number. This will happen
if you have statements like "SELECT COUNT(*) ...". It extracts and
returns the number.
Parameters: dsName - Data source name. Parameters: sql - SQL query statement that return int as the result, e.g. SELECT SUM(column_name).... Parameters: Optional - subtitutes parameter used in prepare statement. |
getCount | public static int getCount(DataSource ds, String sql, Object[] params) throws SQLException(Code) | | Assumes that the specified SQL query returns a number. This will happen
if you have statements like "SELECT COUNT(*) ...". It extracts and
returns the number.
Parameters: dsName - Data source name. Parameters: sql - SQL query statement that return int as the result, e.g. SELECT SUM(column_name).... Parameters: Optional - subtitutes parameter used in prepare statement. |
getDataSource | public static DataSource getDataSource(String dsName) throws javax.naming.NamingException(Code) | | Gets a datbase connection from a datasource that is looked up
using the given JNDI. Note that this will not work in the non-j2ee
configuration
Parameters: dsName - JNDI name for the datasource Database connection exception: java.sql.SQLException - |
getStatus | public static int getStatus() throws javax.transaction.SystemException(Code) | | throws: javax.transaction.SystemException - |
|
|