protected void runSql(ConnectionProvider provider, String sql) throws SQLException { Connection connection = provider.getConnection(); try { Statement statement = connection.createStatement(); statement.execute(sql); } finally { connection.close(); } }
protected String runQuery(ConnectionProvider provider, String query) throws SQLException { Connection connection = provider.getConnection(); try { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); String result = null; if (rs.next()) { result = rs.getString(1); } return result; } finally { connection.close(); } }