| | 227 | |
|---|
| | 228 | /** |
|---|
| | 229 | * Returns the first column of the results of a query as an array of Strings. |
|---|
| | 230 | * @param query the SQL query whose results will be returned in the List |
|---|
| | 231 | * @return a List of Strings from the first columns of the results. |
|---|
| | 232 | * @throws DatabaseException |
|---|
| | 233 | * @throws SQLException |
|---|
| | 234 | */ |
|---|
| | 235 | public String [] getColumnAsArray(String query) |
|---|
| | 236 | throws DatabaseException, SQLException |
|---|
| | 237 | { |
|---|
| | 238 | List list = getColumnAsList(query); |
|---|
| | 239 | String [] array = new String [list.size()]; |
|---|
| | 240 | |
|---|
| | 241 | int index = 0; |
|---|
| | 242 | for (Iterator it = list.iterator(); it.hasNext();) |
|---|
| | 243 | { |
|---|
| | 244 | array[index++] = (String)it.next(); |
|---|
| | 245 | } |
|---|
| | 246 | |
|---|
| | 247 | return array; |
|---|
| | 248 | } |
|---|
| | 250 | /** |
|---|
| | 251 | * Returns the first column of the results of a query as a List of Strings. |
|---|
| | 252 | * @param query the SQL query whose results will be returned in the List |
|---|
| | 253 | * @return a List of Strings from the first columns of the results. |
|---|
| | 254 | * @throws DatabaseException |
|---|
| | 255 | * @throws SQLException |
|---|
| | 256 | */ |
|---|
| | 257 | public List getColumnAsList(String query) |
|---|
| | 258 | throws DatabaseException, SQLException |
|---|
| | 259 | { |
|---|
| | 260 | List results = new ArrayList(); |
|---|
| | 261 | prepareSelect(query); |
|---|
| | 262 | ResultSet rs = select(); |
|---|
| | 263 | |
|---|
| | 264 | while (rs.next()) |
|---|
| | 265 | { |
|---|
| | 266 | results.add(rs.getString(1)); |
|---|
| | 267 | } |
|---|
| | 268 | |
|---|
| | 269 | finish(); |
|---|
| | 270 | return results; |
|---|
| | 271 | } |
|---|
| | 272 | |
|---|