All Packages Class Hierarchy This Package Previous Next Index
Class ibs.util.DbUtils
java.lang.Object
|
+----ibs.util.DbUtils
- public class DbUtils
- extends Object
This class provides certain database utilities that helps eliminate coding of
repetative tasks for dealing with a ResultSet.
- See Also:
- ResultSet, ResultSetMetaData
-
DbUtils()
-
-
columnsToStringArray(ResultSet)
- Generates a String array of column names for the given result set.
-
getColumnCount(ResultSet)
- Returns column count for the given result set.
-
nextRecordToStringArray(ResultSet)
- Generates a String array of record field value for the next record in the given result set.
-
printResultSet(ResultSet, PrintWriter)
- Prints result set contents to the given PrintWriter.
-
printResultSet(ResultSet, PrintWriter, boolean)
- Prints result set contents to the given PrintWriter.
-
printResultSetColumns(ResultSet, PrintWriter)
- Prints result set column names to the given PrintWriter.
-
printResultSetColumns(ResultSetMetaData, PrintWriter)
- Prints result set column names to the given PrintWriter.
DbUtils
public DbUtils()
printResultSet
public void printResultSet(ResultSet rs,
PrintWriter pw) throws SQLException
- Prints result set contents to the given PrintWriter. Primarily this will be helpful
during development environment where you may wish to see the contents of the resultset
or its column names on your screen. Result set will closed automatically at the end.
To get column names displayed on your standard output, just instantiate a PrintWriter
object as new PrintWriter(System.out) and pass it to this method.
- Parameters:
- md - A ResultSet object.
- pw - A PrintWriter where contents should be printed.
- Throws: SQLException
- In case of any sql error ...
printResultSet
public void printResultSet(ResultSet rs,
PrintWriter pw,
boolean close_at_end) throws SQLException
- Prints result set contents to the given PrintWriter. Primarily this will be helpful
during development environment where you may wish to see the contents of the resultset
or its column names on your screen.
To get column names displayed on your standard output, just instantiate a PrintWriter
object as new PrintWriter(System.out) and pass it to this method.
- Parameters:
- md - A ResultSet object.
- pw - A PrintWriter where contents should be printed.
- close_at_end - If you wish not to close the resultset at the end, set this to 'true'
By default this is 'false' and result set will be closed automatically.
- Throws: SQLException
- In case of any sql error ...
getColumnCount
public int getColumnCount(ResultSet rs) throws SQLException
- Returns column count for the given result set. Column count represents
the number of column that formed a record in the result set.
- Parameters:
- rs - A ResultSet object.
printResultSetColumns
public void printResultSetColumns(ResultSet rs,
PrintWriter pw) throws SQLException
- Prints result set column names to the given PrintWriter. Primarily this will be helpful
during development environment where you may wish to see the contents of the resultset
or its column names on your screen.
To get column names displayed on your standard output, just instantiate a PrintWriter
object as new PrintWriter(System.out) and pass it to this method.
NOTE: In some cases, you may have to construct a PrintWriter object with a 'true'
argument to set it to auto flush.
- Parameters:
- rs - A ResultSet object.
- pw - A PrintWriter where contents should be printed.
- Throws: SQLException
- In case of any sql error ...
printResultSetColumns
public void printResultSetColumns(ResultSetMetaData md,
PrintWriter pw) throws SQLException
- Prints result set column names to the given PrintWriter. Primarily this will be helpful
during development environment where you may wish to see the contents of the resultset
or its column names on your screen.
To get column names displayed on your standard output, just instantiate a PrintWriter
object as new PrintWriter(System.out) and pass it to this method.
NOTE: In some cases, you may have to construct a PrintWriter object with a 'true'
argument to set it to auto flush.
- Parameters:
- md - A ResultSetMetaData object.
- pw - A PrintWriter where contents should be printed.
- Throws: SQLException
- In case of any sql error ...
columnsToStringArray
public String[] columnsToStringArray(ResultSet rs) throws SQLException
- Generates a String array of column names for the given result set.
- Parameters:
- rs - A ResultSet object
- Returns:
- A String array containg result set column names.
nextRecordToStringArray
public String[] nextRecordToStringArray(ResultSet rs) throws SQLException
- Generates a String array of record field value for the next record in the given result set.
- Parameters:
- rs - A ResultSet object
- Returns:
- A String array containg field values for the next record in the ResultSet.
Returns null if there are no more records ( call to next() returns false. );
All Packages Class Hierarchy This Package Previous Next Index