static public String extractStringResult ( ResultSet rs , ResultSetMetaData rsmd , int index ) throws Exception { int count = rsmd . getColumnCount ( ) ; if ( index > count || index < 1 ) { throw new Exception ( "Invalid index" ) ; } int type = rsmd . getColumnType ( index ) ; switch ( type ) { case java . sql . Types . VARCHAR : case java . sql . Types . CHAR : return rs . getString ( index ) ; } throw new Exception ( "Column type (" + type + ") invalid for a string at index: " + index ) ; }
This method returns a String result at a given index .