1 19 20 package org.apache.cayenne.dba.oracle; 21 22 import java.sql.Connection ; 23 import java.sql.PreparedStatement ; 24 import java.sql.ResultSet ; 25 import java.sql.SQLException ; 26 import java.util.Collection ; 27 28 import org.apache.cayenne.access.OperationObserver; 29 import org.apache.cayenne.access.QueryLogger; 30 import org.apache.cayenne.access.jdbc.SQLStatement; 31 import org.apache.cayenne.access.jdbc.SQLTemplateAction; 32 import org.apache.cayenne.dba.DbAdapter; 33 import org.apache.cayenne.query.SQLTemplate; 34 35 41 class Oracle8SQLTemplateAction extends SQLTemplateAction { 42 43 Oracle8SQLTemplateAction(SQLTemplate query, DbAdapter adapter) { 44 super(query, adapter); 45 } 46 47 53 protected void execute( 54 Connection connection, 55 OperationObserver callback, 56 SQLStatement compiled, 57 Collection updateCounts) throws SQLException , Exception { 58 59 String sql = compiled.getSql().trim(); 60 boolean select = sql.length() > "SELECT".length() 61 && sql.substring(0, "SELECT".length()).equalsIgnoreCase("SELECT"); 62 63 long t1 = System.currentTimeMillis(); 64 boolean iteratedResult = callback.isIteratedResult(); 65 PreparedStatement statement = connection.prepareStatement(compiled.getSql()); 66 try { 67 bind(statement, compiled.getBindings()); 68 69 if (select) { 71 72 ResultSet resultSet = statement.executeQuery(); 73 try { 74 processSelectResult( 75 compiled, 76 connection, 77 statement, 78 resultSet, 79 callback, 80 t1); 81 } 82 finally { 83 if (!iteratedResult) { 84 resultSet.close(); 85 } 86 } 87 } 88 else { 89 int updateCount = statement.executeUpdate(); 90 updateCounts.add(new Integer (updateCount)); 91 QueryLogger.logUpdateCount(updateCount); 92 } 93 94 } 96 finally { 97 if (!iteratedResult) { 98 statement.close(); 99 } 100 } 101 } 102 } 103 | Popular Tags |