1 24 package org.ofbiz.entity.jdbc; 25 26 import java.lang.reflect.Method ; 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 import java.sql.Statement ; 30 31 36 public class CursorConnection extends AbstractCursorHandler { 37 38 public static Connection newCursorConnection(Connection con, String cursorName, int pageSize) throws Exception { 39 return (Connection ) newHandler(new CursorConnection(con, cursorName, pageSize), Connection .class); 40 } 41 42 protected Connection con; 43 44 protected CursorConnection(Connection con, String cursorName, int fetchSize) { 45 super(cursorName, fetchSize); 46 this.con = con; 47 } 48 49 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable { 50 if (method.getName().equals("prepareStatement")) { 51 System.err.println("prepareStatement"); 52 args[0] = "DECLARE " + cursorName + " CURSOR FOR " + args[0]; 53 PreparedStatement pstmt = (PreparedStatement ) method.invoke(con, args); 54 return CursorStatement.newCursorPreparedStatement(pstmt, cursorName, fetchSize); 55 } else if (method.getName().equals("createStatement")) { 56 System.err.println("createStatement"); 57 Statement stmt = (Statement ) method.invoke(con, args); 58 return CursorStatement.newCursorStatement(stmt, cursorName, fetchSize); 59 } 60 return super.invoke(con, proxy, method, args); 61 } 62 } 63 | Popular Tags |