List:Internals« Previous MessageNext Message »
From:mmatthews Date:August 24 2005 8:26pm
Subject:Connector/J commit: r4136 - branches/branch_5_0/connector-j/src/com/mysql/jdbc
View as plain text  
Modified:
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java
Log:
 CallableStatement.clearParameters() now clears resources associated
      with INOUT/OUTPUT parameters as well as INPUT parameters.

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java	2005-08-24 20:14:50 UTC (rev 4135)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java	2005-08-24 20:26:22 UTC (rev 4136)
@@ -64,18 +64,18 @@
 
 		int index;
 
+		int inOutModifier;
+
 		boolean isIn;
 
 		boolean isOut;
 
+		int jdbcType;
+		short nullability; 
 		String paramName;
-
-		int jdbcType;
-		String typeName; 
-		int precision;
+		int precision; 
 		int scale; 
-		short nullability; 
-		int inOutModifier;
+		String typeName;
 		
 		CallableStatementParam(String name, int idx, boolean in, 
 				boolean out, int jdbcType, String typeName, 
@@ -182,6 +182,18 @@
 			}
 		}
 
+		protected void checkBounds(int paramIndex) throws SQLException {
+			int localParamIndex = paramIndex - 1;
+
+			if ((paramIndex < 0)
+					|| (localParamIndex >= this.numParameters)) {
+				throw new SQLException(
+						Messages.getString("CallableStatement.11") + paramIndex //$NON-NLS-1$
+								+ Messages.getString("CallableStatement.12") + numParameters //$NON-NLS-1$
+								+ Messages.getString("CallableStatement.13"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
+			}
+		}
+
 		/*
 		 * (non-Javadoc)
 		 * 
@@ -200,28 +212,31 @@
 			return (CallableStatementParam) this.parameterMap.get(name);
 		}
 
-		Iterator iterator() {
-			return this.parameterList.iterator();
+		public String getParameterClassName(int arg0) throws SQLException {
+			// TODO Auto-generated method stub
+			return null;
 		}
 
-		int numberOfParameters() {
-			return this.numParameters;
-		}
-
 		public int getParameterCount() throws SQLException {
 			return this.parameterList.size();
 		}
 
-		public int isNullable(int arg0) throws SQLException {
+		public int getParameterMode(int arg0) throws SQLException {
 			checkBounds(arg0);
 			
-			return getParameter(arg0 - 1).nullability;
+			return getParameter(arg0 - 1).inOutModifier;
 		}
 
-		public boolean isSigned(int arg0) throws SQLException {
+		public int getParameterType(int arg0) throws SQLException {
 			checkBounds(arg0);
+			
+			return getParameter(arg0 - 1).jdbcType;
+		}
 
-			return false;
+		public String getParameterTypeName(int arg0) throws SQLException {
+			checkBounds(arg0);
+			
+			return getParameter(arg0 - 1).typeName;
 		}
 
 		public int getPrecision(int arg0) throws SQLException {
@@ -236,39 +251,24 @@
 			return getParameter(arg0 - 1).scale;
 		}
 
-		public int getParameterType(int arg0) throws SQLException {
+		public int isNullable(int arg0) throws SQLException {
 			checkBounds(arg0);
 			
-			return getParameter(arg0 - 1).jdbcType;
+			return getParameter(arg0 - 1).nullability;
 		}
 
-		public String getParameterTypeName(int arg0) throws SQLException {
+		public boolean isSigned(int arg0) throws SQLException {
 			checkBounds(arg0);
-			
-			return getParameter(arg0 - 1).typeName;
-		}
 
-		public String getParameterClassName(int arg0) throws SQLException {
-			// TODO Auto-generated method stub
-			return null;
+			return false;
 		}
 
-		public int getParameterMode(int arg0) throws SQLException {
-			checkBounds(arg0);
-			
-			return getParameter(arg0 - 1).inOutModifier;
+		Iterator iterator() {
+			return this.parameterList.iterator();
 		}
 
-		protected void checkBounds(int paramIndex) throws SQLException {
-			int localParamIndex = paramIndex - 1;
-
-			if ((paramIndex < 0)
-					|| (localParamIndex >= this.numParameters)) {
-				throw new SQLException(
-						Messages.getString("CallableStatement.11") + paramIndex //$NON-NLS-1$
-								+ Messages.getString("CallableStatement.12") + numParameters //$NON-NLS-1$
-								+ Messages.getString("CallableStatement.13"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
-			}
+		int numberOfParameters() {
+			return this.numParameters;
 		}
 	}
 	
@@ -449,6 +449,18 @@
 					SQLError.SQL_STATE_DRIVER_NOT_CAPABLE);
 		}
 	}
+	
+	public synchronized void clearParameters() throws SQLException {
+		super.clearParameters();
+		
+		try {
+			if (this.outputParameterResults != null) {
+				this.outputParameterResults.close();
+			}
+		} finally {
+			this.outputParameterResults = null;
+		}
+	}
 
 	private void determineParameterTypes() throws SQLException {
 		java.sql.ResultSet paramTypesRs = null;

Thread
Connector/J commit: r4136 - branches/branch_5_0/connector-j/src/com/mysql/jdbcmmatthews24 Aug