You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2007/10/26 07:21:54 UTC

svn commit: r588530 - in /db/derby/code/branches/10.3/java: client/org/apache/derby/client/am/PreparedStatement.java testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java

Author: mamta
Date: Thu Oct 25 22:21:53 2007
New Revision: 588530

URL: http://svn.apache.org/viewvc?rev=588530&view=rev
Log:
Migrating changes from trunk(revision 588527) into 10.3. These changes are for DERBY-3046. The commit comments
were as follows in the trunk(revision 588527).

This commit will ensure that setObject returns the same exception in both Network Server and Embedded WHEN the 
PreparedStatement has no parameters associated with it at all. Without the changes that are going in this commit,
following sql will return different exceptions in Embedded and Network Server (this test case is copied from 
derbynet.PrepareStatementTest). 

ps = prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('bb')"); 
ps.setObject(1,"cc",java.sql.Types.VARCHAR); 

ps.setObject in Embedded will throw SQL State 07009 whereas in Network Server, it will throw SQL State XCL13. 
As part of this commit, in the example case above, we will always throw SQL State 07009 in both Embedded and 
Network Server. 


Modified:
    db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java

Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=588530&r1=588529&r2=588530&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java Thu Oct 25 22:21:53 2007
@@ -2409,17 +2409,15 @@
     }
 
     void checkForValidParameterIndex(int parameterIndex) throws SqlException {
-        if (parameterMetaData_ == null || parameterIndex < 1 || parameterIndex > parameterMetaData_.columns_) {
-        	int totalParameters = 0;
-            if (parameterMetaData_ != null)
-            	//Load totalParmeters with correct number of parameters if 
-            	//ParameterMetaData_ is not null. We will need that in the error
-            	//message.
-            	totalParameters = parameterMetaData_.columns_;
+        if (parameterMetaData_ == null) 
+			throw new SqlException(agent_.logWriter_,
+					new ClientMessageId(SQLState.NO_INPUT_PARAMETERS));
+
+        if (parameterIndex < 1 || parameterIndex > parameterMetaData_.columns_) {
             throw new SqlException(agent_.logWriter_, 
                 new ClientMessageId(SQLState.LANG_INVALID_PARAM_POSITION),
                 new Integer(parameterIndex), 
-                new Integer(totalParameters));
+                new Integer(parameterMetaData_.columns_));
         }
     }
 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java?rev=588530&r1=588529&r2=588530&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java Thu Oct 25 22:21:53 2007
@@ -1146,13 +1146,7 @@
         	ps.setObject(1,"cc",java.sql.Types.VARCHAR); 
             fail("Exception expected above!");
         } catch (SQLException e)  {   
-        	if (usingDerbyNetClient())
-        		//note that SQLState is XCL13. For setString above, the 
-        		//SQLState is XCL14. I have entered DERBY-3139 for this
-        		//difference in SQLState.
-        		assertSQLState("XCL13", e);
-        	else
-        		assertSQLState("07009", e);
+    		assertSQLState("07009", e);
         }
     }