db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r392336 - in /db/derby/code/branches/10.1/java: drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
Date Fri, 07 Apr 2006 17:09:26 GMT
Author: djd
Date: Fri Apr  7 10:09:25 2006
New Revision: 392336

URL: http://svn.apache.org/viewcvs?rev=392336&view=rev
Log:
DERBY-1015 (partial) Add an interface for Statement objects from the engine, EngineStatement.
Removes
some use of reflection in brokered objects and the network server. Is also a step towards
solving
DERBY-1158, downgrading holdabilty in global transactions.
Merge of 391691 from trunk.

Added:
    db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
  (props changed)
      - copied unchanged from r391691, db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
Modified:
    db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java

Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=392336&r1=392335&r2=392336&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Fri
Apr  7 10:09:25 2006
@@ -38,6 +38,7 @@
 import org.apache.derby.iapi.jdbc.BrokeredConnection;
 import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
 import org.apache.derby.iapi.jdbc.EngineConnection;
+import org.apache.derby.iapi.jdbc.EngineStatement;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.sql.execute.ExecutionContext;
 import org.apache.derby.iapi.util.StringUtil;
@@ -245,65 +246,47 @@
 
 	/**
 	 *
-	 *  get resultSetHoldability with reflection. 
-	 *  We need to use reflection so we can use hold cursors with 1.3.1. 
-	 *  And also since our statement might be a BrokeredStatement.
+	 *  get resultSetHoldability.
 	 * 
 	 * @return the resultSet holdability for the prepared statement
 	 *
 	 */
 	protected int getResultSetHoldability() throws SQLException
 	{
-		Statement rsstmt = null;
+		Statement rsstmt;
 		ResultSet rs = getResultSet();
-		int holdValue = -1;
 
 		if (rs  != null)
 			rsstmt = rs.getStatement();
 		else
 			rsstmt = getPreparedStatement();
-				
-		Class[] getResultSetHoldabilityParam  = {};
-		try {
-			Method sh =
-				rsstmt.getClass().getMethod("getResultSetHoldability", getResultSetHoldabilityParam);
-			holdValue =  ((Integer) sh.invoke(rsstmt,null)).intValue();
-		}
-		catch (Exception e) {
-			handleReflectionException(e);
-		}
+        
+        int holdValue = 
+            ((EngineStatement) rsstmt).getResultSetHoldability();
+
 		return holdValue;
 	}
 	
 	/**
 	 *
-	 *  get resultSetHoldability with reflection. 
-	 *  We need to use reflection so we can use hold cursors with 1.3.1. 
-	 *  And also since our statement might be a BrokeredStatement.
+	 *  get resultSetHoldability.
 	 * 
 	 * @param rs ResultSet 
 	 * @return the resultSet holdability for the prepared statement
 	 *
 	 */
-	protected int getResultSetHoldability(ResultSet rs) throws SQLException
+	int getResultSetHoldability(ResultSet rs) throws SQLException
 	{
-		Statement rsstmt = null;
-		int holdValue = -1;
+		Statement rsstmt;
 
 		if (rs  != null)
 			rsstmt = rs.getStatement();
 		else
 			rsstmt = getPreparedStatement();
-				
-		Class[] getResultSetHoldabilityParam  = {};
-		try {
-			Method sh =
-				rsstmt.getClass().getMethod("getResultSetHoldability", getResultSetHoldabilityParam);
-			holdValue =  ((Integer) sh.invoke(rsstmt,null)).intValue();
-		}
-		catch (Exception e) {
-			handleReflectionException(e);
-		}
+        
+        int holdValue = 
+            ((EngineStatement) rsstmt).getResultSetHoldability();
+
 		return holdValue;
 	}	
 
@@ -1554,22 +1537,10 @@
 	 * @see java.sql.Statement#getMoreResults
 	 *
 	 */
-	protected boolean getMoreResults(int current) throws SQLException
-	{
-		boolean retVal = false;
-		Class[] intPARAM = {Integer.TYPE};
-		Object[] args = {new Integer(current)};
-		try {
-			Method sh = getPreparedStatement().getClass().getMethod("getMoreResults",intPARAM);
-			Boolean retObj = (Boolean) sh.invoke(getPreparedStatement(),args);
-			retVal = retObj.booleanValue();
-		}
-		catch (Exception e)
-		{
-			
-			handleReflectionException(e);
-		}
-		return retVal;
+	private boolean getMoreResults(int current) throws SQLException
+	{       
+        return
+            ((EngineStatement) getPreparedStatement()).getMoreResults(current);
 	}
 
 	/**

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=392336&r1=392335&r2=392336&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
Fri Apr  7 10:09:25 2006
@@ -36,7 +36,7 @@
 /**
 	A Statement implementation that forwards all of its requests to an underlying Statement.
  */
-public class BrokeredStatement implements Statement
+public class BrokeredStatement implements EngineStatement
 {
 
 	/**
@@ -441,7 +441,7 @@
      */
 	public final boolean getMoreResults(int current) throws SQLException
     {
-        return getStatement().getMoreResults( current);
+        return ((EngineStatement) getStatement()).getMoreResults( current);
 	}
 
     /**
@@ -464,19 +464,7 @@
 	public final int getResultSetHoldability()
         throws SQLException
 	{
-		int defaultHoldability = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
-		if (JVMInfo.JDK_ID >= JVMInfo.J2SE_14) { //No need to use reflection for jdks 1.4 and
higher
-			defaultHoldability = getStatement().getResultSetHoldability();
-		} else {
-			try {
-				Method sh = getStatement().getClass().getMethod("getResultSetHoldability", null);
-				defaultHoldability = ((Integer)sh.invoke(getStatement(), null)).intValue();
-			} catch( Exception e)
-			{
-				throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e));
-			}
-		}
-		return defaultHoldability;
+		return ((EngineStatement) getStatement()).getResultSetHoldability();
 	}
 
 	/*

Propchange: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=392336&r1=392335&r2=392336&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
Fri Apr  7 10:09:25 2006
@@ -32,6 +32,7 @@
 import org.apache.derby.iapi.sql.ParameterValueSet;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.jdbc.EngineStatement;
 
 import java.sql.SQLException;
 import java.sql.SQLWarning;
@@ -58,7 +59,7 @@
  * @author ames
  */
 public class EmbedStatement extends ConnectionChild
-    implements java.sql.Statement {
+    implements EngineStatement {
 
 	private final java.sql.Connection applicationConnection;
 



Mime
View raw message