db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r292830 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTe...
Date Fri, 30 Sep 2005 18:23:17 GMT
Author: mikem
Date: Fri Sep 30 11:23:06 2005
New Revision: 292830

URL: http://svn.apache.org/viewcvs?rev=292830&view=rev
Log:
fix of DERBY-562, committing patch for: Sunitha Kambhampati

 This patch
 - changes the error message thrown when the stream is either less or greater than the requested
length to
 'Input stream did not have exact amount of data as the requested length.'
 - enhances the characterStreams.out test, to print out the nested sql exceptions to ensure
that the proper error message is returned.
 - updates to the master files.

 I verified that we are testing for these two error cases (ie stream has less or more data
than requested length), for the following supported stream related api - setCharacterStream,
setAsciiStream, setBinaryStream on PreparedStatement. Derby does not support setUnicodeStream
api that is deprecated in jdbc 3.0. 



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/SQLState.java Fri Sep
30 11:23:06 2005
@@ -1360,7 +1360,7 @@
     String TYPE_MISMATCH = "XJ020.S";
     String INVALID_JDBCTYPE = "XJ021.S";
     String SET_STREAM_FAILURE = "XJ022.S";
-    String SET_STREAM_INSUFFICIENT_DATA = "XJ023.S";
+    String SET_STREAM_INEXACT_LENGTH_DATA = "XJ023.S";
     String SET_UNICODE_INVALID_LENGTH = "XJ024.S";
     String NEGATIVE_STREAM_LENGTH = "XJ025.S";
     String NO_AUTO_COMMIT_ON = "XJ030.S";

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/RawToBinaryFormatStream.java
Fri Sep 30 11:23:06 2005
@@ -79,7 +79,7 @@
 		int remainingBytes = clearLimit();
 
 		if (remainingBytes > 0)
-			throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+			throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
 
 		// if we had a limit try reading one more byte.
 		// JDBC 3.0 states the stream muct have the correct number of characters in it.
@@ -93,7 +93,7 @@
 				c = -1;
 			}
 			if (c >= 0)
-				throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+				throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ReaderToUTF8Stream.java Fri
Sep 30 11:23:06 2005
@@ -160,7 +160,7 @@
 		int remainingBytes = reader.clearLimit();
 
 		if (remainingBytes > 0)
-			throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+			throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
 
 		// if we had a limit try reading one more character.
 		// JDBC 3.0 states the stream muct have the correct number of characters in it.
@@ -174,7 +174,7 @@
 				c = -1;
 			}
 			if (c >= 0)
-				throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INSUFFICIENT_DATA));
+				throw new IOException(MessageService.getTextMessage(SQLState.SET_STREAM_INEXACT_LENGTH_DATA));
 		}
 
 		// can put the correct length into the stream.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Fri Sep 30
11:23:06 2005
@@ -1063,7 +1063,7 @@
 XJ018.S=Column name cannot be null.
 XJ020.S=Object type not convertible to TYPE ''{0}'', invalid java.sql.Types value, or object
was null.
 XJ022.S=Unable to set stream: ''{0}''.
-XJ023.S=Input stream held less data than requested length.
+XJ023.S=Input stream did not have exact amount of data as the requested length.
 XJ025.S=Input stream cannot have negative length.
 XJ030.S=Cannot set AUTOCOMMIT ON when in a nested connection.
 XJ042.S=''{0}'' is not a valid value for property ''{1}''.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/characterStreams.out
Fri Sep 30 11:23:06 2005
@@ -2,9 +2,13 @@
 Test setAsciiStream into CHAR
 CORRECT NUMBER OF BYTES IN STREAM
 MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 NULL ASCII STREAM
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
@@ -22,9 +26,13 @@
 Test setAsciiStream into VARCHAR
 CORRECT NUMBER OF BYTES IN STREAM
 MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 NULL ASCII STREAM
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
@@ -42,9 +50,13 @@
 Test setAsciiStream into LONG VARCHAR
 CORRECT NUMBER OF BYTES IN STREAM
 MORE BYTES IN STREAM THAN PASSED IN VALUE
-MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 LESS BYTES IN STREAM THAN PASSED IN VALUE
-LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 NULL ASCII STREAM
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
@@ -60,24 +72,36 @@
 9,<NULL>,<NULL>,Lieberman ran with Gore
 12,<NULL>,<NULL>,<NULL>
 Test setCharacterStream into CHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
 13         |A Mississippi Republican |24         |NULL                     |NULL       |NULL
                    |NULL       
 14         |Lott has apologized      |19         |NULL                     |NULL       |NULL
                    |NULL       
 17         |NULL                     |NULL       |NULL                     |NULL       |NULL
                    |NULL       
 Test setCharacterStream into VARCHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
 18         |NULL                     |NULL       |A Mississippi Republican |24         |NULL
                    |NULL       
 19         |NULL                     |NULL       |Lott has apologized      |19         |NULL
                    |NULL       
 22         |NULL                     |NULL       |NULL                     |NULL       |NULL
                    |NULL       
 Test setCharacterStream into LONG VARCHAR
-MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
-LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED SQL Exception: An IOException
was thrown when reading a 'java.sql.String' from an InputStream.
+MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
+LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED 
+EXPECTED SQL Exception: (XCL30) An IOException was thrown when reading a 'java.sql.String'
from an InputStream.
+EXPECTED SQL Exception: (XJ001) Java exception: 'Input stream did not have exact amount of
data as the requested length.: java.io.IOException'.
 ID         |C                        |CLEN       |VC                       |VCLEN      |LVC
                     |LVCLEN     
 -----------------------------------------------------------------------------------------------------------------------------
 23         |NULL                     |NULL       |NULL                     |NULL       |A
Mississippi Republican |24         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
Fri Sep 30 11:23:06 2005
@@ -10,7 +10,7 @@
 len=56
 number of reads=56
 EXPECTED SQLSTATE(XSDA4): An unexpected exception was thrown
-EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream held less data than requested length.:
java.io.IOException'.
+EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream did not have exact amount of data
as the requested length.: java.io.IOException'.
 EXPECTED SQLSTATE(XSDA4): An unexpected exception was thrown
-EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream held less data than requested length.:
java.io.IOException'.
+EXPECTED SQLSTATE(XJ001): Java exception: 'Input stream did not have exact amount of data
as the requested length.: java.io.IOException'.
 Test resultsetStream finished

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java?rev=292830&r1=292829&r2=292830&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/characterStreams.java
Fri Sep 30 11:23:06 2005
@@ -83,6 +83,21 @@
 		System.out.println("Test characterStreams finished");
   }
 
+    
+    
+       private static void expectedException(SQLException sqle) {
+
+        while (sqle != null) {
+            String sqlState = sqle.getSQLState();
+            if (sqlState == null) {
+                sqlState = "<NULL>";
+            }
+            System.out.println("EXPECTED SQL Exception: (" + sqlState + ") "
+                    + sqle.getMessage());
+
+            sqle = sqle.getNextException();
+        }
+    }
 	static void setStreams(Connection conn) throws Exception {
 
 		ResultSet rs;
@@ -227,7 +242,8 @@
 			ps.executeUpdate();
 			System.out.println("FAIL - MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - ACCEPTED");
 		} catch (SQLException sqle) {
-			System.out.println("MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+			System.out.println("MORE BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED ");
+            expectedException(sqle);
 		}
 
 		// more bytes than the stream contains
@@ -238,7 +254,8 @@
 			ps.executeUpdate();
 			System.out.println("FAIL - LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - ACCEPTED");
 		} catch (SQLException sqle) {
-			System.out.println("LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+			System.out.println("LESS BYTES IN ASCII STREAM THAN SPECIFIED LENGTH - REJECTED ");
+            expectedException(sqle);
 		}
 
 		// null
@@ -263,7 +280,8 @@
 			ps.executeUpdate();
 			System.out.println("FAIL - MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - ACCEPTED");
 		} catch (SQLException sqle) {
-			System.out.println("MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED " + sqle.toString());
+			System.out.println("MORE CHARACTERS IN READER THAN SPECIFIED LENGTH - REJECTED ");
+            expectedException(sqle);
 		}
 
 		// more bytes than the stream contains,
@@ -273,7 +291,8 @@
 			ps.executeUpdate();
 			System.out.println("FAIL - LESS CHARACTERS IN READER THAN SPECIFIED LENGTH - ACCEPTED");
 		} catch (SQLException sqle) {
-			System.out.println("LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED
" + sqle.toString());
+			System.out.println("LESS CHARACTERS IN READER STREAM THAN SPECIFIED LENGTH - REJECTED
");
+            expectedException(sqle);
 		}
 
 		// null



Mime
View raw message