01: package com.vividsolutions.jump.datastore.jdbc;
02:
03: import java.sql.*;
04: import com.vividsolutions.jump.datastore.*;
05:
06: /**
07: * Utilities for JDBC.
08: *
09: * @author Martin Davis
10: * @version 1.0
11: */
12: public class JDBCUtil {
13: public static void execute(Connection conn, String sql,
14: ResultSetBlock block) {
15: try {
16: Statement statement = conn.createStatement();
17: try {
18: ResultSet resultSet = statement.executeQuery(sql);
19: try {
20: block.yield(resultSet);
21: } finally {
22: resultSet.close();
23: }
24: } finally {
25: statement.close();
26: }
27: } catch (Exception e) {
28: throw new RuntimeException(e);
29: }
30: }
31: }
|