Performs the given SQL query and return the first row of the result set. Example usage: def ans = sql.firstRow("select from PERSON where firstname like 'S%'") println ans.firstname Resource handling is performed automatically where appropriate. @param sql the SQL statement @ret
(String sql)
| 2489 | * @throws SQLException if a database access error occurs |
| 2490 | */ |
| 2491 | public GroovyRowResult firstRow(String sql) throws SQLException { |
| 2492 | List<GroovyRowResult> rows = null; |
| 2493 | try { |
| 2494 | rows = rows(sql, 1, 1, null); |
| 2495 | } |
| 2496 | //should be SQLFeatureNotSupportedException instead once we move to Java 1.6 |
| 2497 | catch (SQLException featureNotSupportedException) { |
| 2498 | rows = rows(sql); |
| 2499 | } |
| 2500 | if (rows.isEmpty()) return null; |
| 2501 | return rows.get(0); |
| 2502 | } |
| 2503 | |
| 2504 | /** |
| 2505 | * Performs the given SQL query and return |
nothing calls this directly
no test coverage detected