com.jamonapi.utils
Class ResultSetUtils

java.lang.Object
  |
  +--com.jamonapi.utils.ResultSetUtils

public class ResultSetUtils
extends java.lang.Object

Purpose: Provides various methods for obtaining resultset data. Author: Andy Evans Date: 3/28/2001


Method Summary
 java.lang.String[][] arrayListToString(java.util.ArrayList arrayList)
          The following method converts an ArrayList, containing string arrays of ResultSet row data, into a two dimensional string array.
static ResultSetUtils createInstance()
           
 void fullResultSetToArrayList(java.util.ArrayList arrayList, java.sql.ResultSet resultSet)
          The following method returns an ArrayList containing the ResultSet column names and data.
 java.lang.String[][] fullResultSetToString(java.sql.ResultSet resultSet)
          The following method simply takes the ResultSet and converts it to a two dimensional array of strings containing the column names and data using calls to the resultSetToArrayList and arrayListToString methods.
 java.lang.String[] getColumnNames(java.sql.ResultSetMetaData resultSetMetaData)
          The following method returns an array of strings containing the column names for a given ResultSetMetaData object.
 java.lang.String[] getColumnNames(java.sql.ResultSetMetaData resultSetMetaData, int[] returnCols)
          The following method returns an array of strings containing the column names for a given ResultSetMetaData object.
 void resultSetMetaDataToArrayList(java.util.ArrayList arrayList, java.sql.ResultSet resultSet)
          The following method returns an ArrayList containing the ResultSetMetaData column names.
 void resultSetToArrayList(java.util.ArrayList arrayList, java.sql.ResultSet resultSet)
          The following method returns an ArrayList containing the ResultSet column names and data.
 void resultSetToMap(java.util.Map map, java.sql.ResultSet resultSet)
          The following method converts ResultSet data to a Map of object keys and values using an instance of HashMap.
 java.lang.String[][] resultSetToString(java.sql.ResultSet resultSet)
          The following method simply takes the ResultSet and converts it to a two dimensional array of strings containing the column names and data using calls to the resultSetToArrayList and arrayListToString methods.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstance

public static ResultSetUtils createInstance()

fullResultSetToArrayList

public void fullResultSetToArrayList(java.util.ArrayList arrayList,
                                     java.sql.ResultSet resultSet)
                              throws java.sql.SQLException
The following method returns an ArrayList containing the ResultSet column names and data. The first row of the ArrayList will always contain a string array of the column names. Subsequent rows contain ResultSet rows as object arrays. The getColumnNames() method is called to get the column names string array, and the getRowData() to convert ResultSet row data into an object array.

java.sql.SQLException

resultSetToArrayList

public void resultSetToArrayList(java.util.ArrayList arrayList,
                                 java.sql.ResultSet resultSet)
                          throws java.sql.SQLException
The following method returns an ArrayList containing the ResultSet column names and data. The first row of the ArrayList will always contain a string array of the column names. Subsequent rows contain ResultSet rows as object arrays. The getColumnNames() method is called to get the column names string array, and the getRowData() to convert ResultSet row data into an object array.

java.sql.SQLException

resultSetMetaDataToArrayList

public void resultSetMetaDataToArrayList(java.util.ArrayList arrayList,
                                         java.sql.ResultSet resultSet)
                                  throws java.sql.SQLException
The following method returns an ArrayList containing the ResultSetMetaData column names. There is only 1 row in the ArrayList and it will always contain a string array of the column names.

java.sql.SQLException

resultSetToMap

public void resultSetToMap(java.util.Map map,
                           java.sql.ResultSet resultSet)
                    throws java.sql.SQLException
The following method converts ResultSet data to a Map of object keys and values using an instance of HashMap. The first column in the ResultSet supplies the key, the second column the value. If the ResultSet contains more than two columns then subsequent columns are ignored. If the ResultSet supplies only one column then an SQLException is thrown. The ResultSet values are converted to objects using the getRowData() method which converts a ResultSet row into an array of objects.

java.sql.SQLException

arrayListToString

public java.lang.String[][] arrayListToString(java.util.ArrayList arrayList)
The following method converts an ArrayList, containing string arrays of ResultSet row data, into a two dimensional string array. This array must be first initialized before it can be passed as an argument to the ArrayList toArray() method. The first dimension represents the number of rows, including the column names, and can be obtained from the ArrayList size() method which returns the number of elements in the ArrayList. The second dimension represents the number of columns. This value is obtained from the length of the string array in the first element of the ArrayList since: 1. The length of all the string arrays in the ArrayList must be the same. 2. There must also be at least one row in the ArrayList representing the column names.


resultSetToString

public java.lang.String[][] resultSetToString(java.sql.ResultSet resultSet)
                                       throws java.sql.SQLException
The following method simply takes the ResultSet and converts it to a two dimensional array of strings containing the column names and data using calls to the resultSetToArrayList and arrayListToString methods.

java.sql.SQLException

fullResultSetToString

public java.lang.String[][] fullResultSetToString(java.sql.ResultSet resultSet)
                                           throws java.sql.SQLException
The following method simply takes the ResultSet and converts it to a two dimensional array of strings containing the column names and data using calls to the resultSetToArrayList and arrayListToString methods.

java.sql.SQLException

getColumnNames

public java.lang.String[] getColumnNames(java.sql.ResultSetMetaData resultSetMetaData)
                                  throws java.sql.SQLException
The following method returns an array of strings containing the column names for a given ResultSetMetaData object.

java.sql.SQLException

getColumnNames

public java.lang.String[] getColumnNames(java.sql.ResultSetMetaData resultSetMetaData,
                                         int[] returnCols)
                                  throws java.sql.SQLException
The following method returns an array of strings containing the column names for a given ResultSetMetaData object. NEW CODE

java.sql.SQLException