Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Firebird Open Source J2ee connector - jdbc driver
  *
  * Distributable under LGPL license.
  * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * LGPL License for more details.
 *
 * This file was created by members of the firebird development team.
 * All individual contributions remain the Copyright (C) of those
 * individuals.  Contributors to this file are either listed here or
 * can be obtained from a CVS history command.
 *
 * All rights reserved.
 */
package org.firebirdsql.pool;
import static org.firebirdsql.ds.ReflectionHelper.findMethod;
Wrapper for result sets. This class watches the java.sql.ResultSet.getStatement() invocations and substitutes the result of the method call with the proxy wrapping corresponding prepared statement.

Author(s):
Roman Rokytskyy
public class ResultSetHandler implements InvocationHandler {
    
    private final static Method RESULT_SET_GET_STATEMENT = findMethod(
        ResultSet.class"getStatement"new Class[0]);
        
        
    private Statement owner;
    private ResultSet target;
    
    
Create instance of this class for the specified prepared statement proxy and target result set.

Parameters:
owner dynamic proxy implementing java.sql.PreparedStatement interface that generated result set to wrap.
target result set to wrap.
    public ResultSetHandler(Statement ownerResultSet target) {
        this. = owner;
        this. = target;
    } 
        
    
Implementation of the dynamic proxy handler interface.
	public Object invoke(Object proxyMethod methodObject[] argsthrows Throwable {
        
        if (.equals(method))
            return ;
        else { 
            try {
                return method.invoke(args);
            } catch(InvocationTargetException ex) {
                if (ex.getTargetException() instanceof SQLException)
                    throw ex.getTargetException();
                else
                    throw ex;
            }
        }
	}
New to GrepCode? Check out our FAQ X