db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: rev 55251 - incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc
Date Thu, 21 Oct 2004 19:28:20 GMT
Author: djd
Date: Thu Oct 21 12:28:19 2004
New Revision: 55251

Modified:
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
Log:
Ensure BrokeredStatement and PreparedStatement always throw
a Statement is closed exception if the statement is closed.


Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
Thu Oct 21 12:28:19 2004
@@ -50,7 +50,7 @@
      */
 	public final ResultSet executeQuery() throws SQLException
     {
-		control.checkHoldCursors(resultSetHoldability);
+		controlCheck().checkHoldCursors(resultSetHoldability);
         return wrapResultSet(getPreparedStatement().executeQuery());
     } 
 
@@ -418,7 +418,7 @@
      */
     public final boolean execute() throws SQLException
     {
-		control.checkHoldCursors(resultSetHoldability);
+		controlCheck().checkHoldCursors(resultSetHoldability);
         return getPreparedStatement().execute();
     }
 

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
Thu Oct 21 12:28:19 2004
@@ -35,7 +35,9 @@
     private static final String copyrightNotice = org.apache.derby.iapi.reference.Copyright.SHORT_2003_2004;
 
 	/**
-		My control.
+		My control. Use the controlCheck() method to obtain the control
+		when calling a check method. This will result in the correct exception
+		being thrown if the statement is already closed.
 	*/
 	protected final BrokeredStatementControl control;
 
@@ -91,13 +93,13 @@
 
     public final boolean execute(String sql) throws SQLException
 	{
-		control.checkHoldCursors(resultSetHoldability);
+		controlCheck().checkHoldCursors(resultSetHoldability);
 		return getStatement().execute(sql);
     } 
 
     public final ResultSet executeQuery(String sql) throws SQLException
 	{
-		control.checkHoldCursors(resultSetHoldability);
+		controlCheck().checkHoldCursors(resultSetHoldability);
 		return wrapResultSet(getStatement().executeQuery(sql));
     }
 
@@ -508,5 +510,17 @@
 	}
 	protected final ResultSet wrapResultSet(ResultSet rs) {
 		return control.wrapResultSet(rs);
+	}
+
+	/**
+		Get the BrokeredStatementControl in order to perform a check.
+		Obtained indirectly to ensure that the correct exception is
+		thrown if the Statement has been closed.
+	*/
+	protected final BrokeredStatementControl controlCheck() throws SQLException
+	{
+		// simplest method that will throw an exception if the Statement is closed
+		getStatement().getConnection();
+		return control;
 	}
 }

Mime
View raw message