protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call, idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call,idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call, idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call, idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call,idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
protected static GroovyResultSet getImpl(CallableStatement call, int idx) { GroovyResultSetProxy proxy = new GroovyResultSetProxy(new CallResultSet(call,idx)); return proxy.getImpl(); } }
/** * Invokes a method for the GroovyResultSet. * This will try to invoke the given method first on the extension * and then on the result set given as proxy parameter. * * @param proxy the result set * @param method the method name of this method will be used * to make a call on the extension. If this fails the call will be * done on the proxy instead * @param args for the call * @see ResultSet * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
/** * Overridden to fix passing the resultset to the closure */ @Override public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException { AbstractQueryCommand command = createQueryCommand(sql); ResultSet results = null; try { results = command.execute(); if (metaClosure != null) metaClosure.call(results.getMetaData()); GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); while (groovyRS.next()) { rowClosure.call(groovyRS); } } catch (SQLException e) { LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage()); throw e; } finally { command.closeResources(); } }
/** * Performs the given SQL query calling closures for metadata and each row * * @param sql the sql statement * @param metaClosure called for meta data (only once after sql execution) * @param rowClosure called for each row with a GroovyResultSet * @throws SQLException if a database access error occurs */ public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException { Connection connection = createConnection(); Statement statement = createConnection(connection); configure(statement); ResultSet results = null; try { log.fine(sql); results = statement.executeQuery(sql); if (metaClosure != null) metaClosure.call(results.getMetaData()); GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); while (groovyRS.next()) { rowClosure.call(groovyRS); } } catch (SQLException e) { log.log(Level.FINE, "Failed to execute: " + sql, e); throw e; } finally { closeResources(connection, statement, results); } }
/** * Performs the given SQL query calling closures for metadata and each row * * @param sql the sql statement * @param metaClosure called for meta data (only once after sql execution) * @param rowClosure called for each row with a GroovyResultSet * @throws SQLException if a database access error occurs */ public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException { Connection connection = createConnection(); Statement statement = getStatement(connection, sql); configure(statement); ResultSet results = null; try { log.fine(sql); results = statement.executeQuery(sql); if (metaClosure != null) metaClosure.call(results.getMetaData()); GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); while (groovyRS.next()) { rowClosure.call(groovyRS); } } catch (SQLException e) { log.log(Level.FINE, "Failed to execute: " + sql, e); throw e; } finally { closeResources(connection, statement, results); } }
Object o = statement.getObject(indx + 1); if (o instanceof ResultSet) { results.add(new GroovyResultSetProxy((ResultSet) o).getImpl()); } else { results.add(o);
results = statement.executeQuery(); GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); while (groovyRS.next()) { closure.call(groovyRS);
Object o = statement.getObject(indx + 1); if (o instanceof ResultSet) { results.add(new GroovyResultSetProxy((ResultSet) o).getImpl()); } else { results.add(o);
GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); groovyRS.eachRow(rowClosure); } catch (SQLException e) {
GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl(); while (groovyRS.next()) { closure.call(groovyRS);