Changeset 175

Show
Ignore:
Timestamp:
12/19/07 20:16:42 (1 year ago)
Author:
chris
Message:

Catch SQLException and throw DatabaseException? in getTableAsList().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lex/trunk/src/com/qwirx/db/sql/SqlDatabase.java

    r170 r175  
    229229 
    230230    public List getTableAsList(String query) 
    231         throws DatabaseException, SQLException 
     231        throws DatabaseException 
    232232        { 
    233             List results = new ArrayList(); 
    234             prepareSelect(query); 
    235              
    236             ResultSet rs = select(); 
    237             int cols = rs.getMetaData().getColumnCount(); 
    238              
    239             while (rs.next()) 
    240             { 
    241                 String [] result = new String [cols]; 
    242                 for (int i = 0; i < cols; i++) 
    243                 { 
    244                     result[i] = rs.getString(i+1); 
    245                 } 
    246                 results.add(result); 
    247             } 
    248              
    249             finish(); 
    250              
    251             return results; 
     233        try 
     234        { 
     235                    List results = new ArrayList(); 
     236                    prepareSelect(query); 
     237                     
     238                    ResultSet rs = select(); 
     239                    int cols = rs.getMetaData().getColumnCount(); 
     240                     
     241                    while (rs.next()) 
     242                    { 
     243                        String [] result = new String [cols]; 
     244                        for (int i = 0; i < cols; i++) 
     245                        { 
     246                            result[i] = rs.getString(i+1); 
     247                        } 
     248                        results.add(result); 
     249                    } 
     250                     
     251                    finish(); 
     252                     
     253                    return results; 
     254        } 
     255        catch (SQLException e) 
     256        { 
     257                throw new DatabaseException("Failed to get database table " + 
     258                                "as List", e, query); 
     259        } 
    252260        } 
    253261