db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r391086 [3/3] - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNetClient/ master/DerbyNetClient/jdk14/ master/DerbyNetClient/jdk16/ tests/jdbcapi/
Date Mon, 03 Apr 2006 17:13:58 GMT
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/parameterMapping.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/parameterMapping.java?rev=391086&r1=391085&r2=391086&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/parameterMapping.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/parameterMapping.java
Mon Apr  3 10:13:55 2006
@@ -1093,18 +1093,9 @@
 			msg = " JDBC FAIL " + SQLTypes[type];
 		}
 		else {
-			if (sqleResult == null)
+			msg = checkForInvalidConversion(sqleResult);
+			if (msg == null)
 				return;
-
-			// XCL12 is temp
-			if ("22005".equals(sqleResult.getSQLState()) || "XCL12".equals(sqleResult.getSQLState()))
-				System.out.print("IC");
-			else if (sqleResult.getMessage().indexOf("Illegal Conv") != -1)
-				System.out.print("IC");
-			else 
-				showException(sqleResult);
-
-			msg = " JDBC MATCH (INVALID)";
 		}
 
 		System.out.println(msg);
@@ -1121,45 +1112,51 @@
 			msg = " JDBC FAIL " + SQLTypes[type];
 		}
 		else {
-			if (sqleResult == null)
+			msg = checkForInvalidConversion(sqleResult);
+			if (msg == null)
 				return;
-
-			// XCL12 is temp
-			if ("22005".equals(sqleResult.getSQLState()) || "XCL12".equals(sqleResult.getSQLState()))
-				System.out.print("IC");
-			else if (sqleResult.getMessage().indexOf("Illegal Conv") != -1)
-				System.out.print("IC");
-			else 
-				showException(sqleResult);
-
-			msg = " JDBC MATCH (INVALID)";
 		}
 
 		System.out.println(msg);
 	}
-	private static void setXXX(Statement s, PreparedStatement psi, PreparedStatement psq, int
type) throws SQLException, java.io.IOException {
+	/**
+	 * Look for an "Invalid Conversion" exception and format it for display.
+	 *
+	 * Look for an "Invalid Conversion" exception. If one is found,
+	 * print "IC". If one is not found, dump the actual exception to
+	 * the output instead.
+	 * 
+	 * Note that the actual invalid conversion exception may be wrapped
+	 * inside a BatchUpdateException, so we may need to hunt through
+	 * the exception chain to find it.
+     */
+	private static String checkForInvalidConversion(SQLException sqle)
+	{
+		if (sqle == null)
+			return null;
 
-		boolean executeBatchTests = true;
-		
-		// DERBY-349 - Disable executeBatch on these target types as invald conversions
-		// using setByte() and executeBatch lead to the test hanging.
-		if (TestUtil.isDerbyNetClientFramework())
-		{		
-			switch (jdbcTypes[type])
+		boolean unknownException = true;
+		SQLException e = sqle;
+		while (e != null && unknownException == true)
+		{
+			// XCL12 is temp
+			if ("22005".equals(e.getSQLState()) ||
+				"XCL12".equals(e.getSQLState()) ||
+				e.getMessage().indexOf("Illegal Conv") != -1)
 			{
-			case Types.BINARY:
-			case Types.VARBINARY:
-			case Types.LONGVARBINARY:
-			case Types.DATE:
-			case Types.TIMESTAMP:
-			case Types.TIME:
-			case Types.CLOB:
-			case Types.BLOB:
-				executeBatchTests = false;
+				unknownException = false;
+				System.out.print("IC");
 				break;
 			}
+			e = e.getNextException();
 		}
-			
+		if (unknownException)
+			showException(sqle);
+
+		return " JDBC MATCH (INVALID)";
+	}
+	private static void setXXX(Statement s, PreparedStatement psi, PreparedStatement psq, int
type) throws SQLException, java.io.IOException {
+
 		
 		{
 		s.execute("DELETE FROM PM.TYPE_AS");
@@ -1182,7 +1179,7 @@
 		judge_setXXX(worked, sqleResult, 0, type);
 		}
 		// and as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1224,7 +1221,7 @@
 		judge_setXXX(worked, sqleResult, 1, type);
 		}
 		// and as a batch
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 			
 		SQLException sqleResult = null;
@@ -1266,7 +1263,7 @@
 		judge_setXXX(worked, sqleResult, 2, type);
 		}
 		// and as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1308,7 +1305,7 @@
 		judge_setXXX(worked, sqleResult, 3, type);
 		}
 		// as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1352,7 +1349,7 @@
 		}
 		
 		// and as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1396,7 +1393,7 @@
 		}
 		
 		// as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1441,7 +1438,7 @@
 		judge_setXXX(worked, sqleResult, 6, type);
 		}
 		// as a batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1485,7 +1482,7 @@
 		}
 
 		// null BigDecimal
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 
 		SQLException sqleResult = null;
@@ -1528,7 +1525,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 7, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1576,7 +1573,7 @@
 		judge_setXXX(worked, sqleResult, 8, type);
 		}
 		// as batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1632,7 +1629,7 @@
 		judge_setXXX(worked, sqleResult, 8, type);
 		}
 		// null String as batch
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 
 		SQLException sqleResult = null;
@@ -1686,7 +1683,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 9, type);
 		}
-		if (executeBatchTests){
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1730,7 +1727,7 @@
 		judge_setXXX(worked, sqleResult, 9, type);
 		}
 
-		if (executeBatchTests){
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1771,7 +1768,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 10, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1815,7 +1812,7 @@
 		}
 		
 		// null Date
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 
 		SQLException sqleResult = null;
@@ -1857,7 +1854,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 11, type);
 		}
-		if (executeBatchTests){
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1899,7 +1896,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 11, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1941,7 +1938,7 @@
 		judge_setXXX(worked, sqleResult, 12, type);
 		}
 		// as batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -1984,7 +1981,7 @@
 		judge_setXXX(worked, sqleResult, 12, type);
 		}
 		// as batch
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2033,7 +2030,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 13, type);
 		}
-		if (executeBatchTests){
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2082,7 +2079,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 13, type);
 		}
-		if (executeBatchTests){
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2129,7 +2126,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 14, type);
 		}	
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2177,7 +2174,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 14, type);
 		}	
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2217,7 +2214,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 15, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2257,7 +2254,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 15, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2304,7 +2301,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 16, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2353,7 +2350,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 16, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;
@@ -2399,7 +2396,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 17, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 			SQLException sqleResult = null;
 			boolean worked;
@@ -2444,7 +2441,7 @@
 		}
 		judge_setXXX(worked, sqleResult, 17, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 			SQLException sqleResult = null;
 			boolean worked;
@@ -2527,7 +2524,7 @@
 
 
 		// setObject(null)
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 
 		SQLException sqleResult = null;
@@ -2547,7 +2544,7 @@
 		}
 		System.out.println(worked ? " FAIL " : (" OK " + sqleResult.getMessage()));
 		}
-		if (executeBatchTests) {
+		{
 		s.execute("DELETE FROM PM.TYPE_AS");
 
 		SQLException sqleResult = null;
@@ -2569,24 +2566,24 @@
 		System.out.println(worked ? " FAIL " : (" OK " + sqleResult.getMessage()));
 		}
 
-		setXXX_setObject(s, psi, psq, type, "46", "java.lang.String", 0, executeBatchTests);
+		setXXX_setObject(s, psi, psq, type, "46", "java.lang.String", 0);
 		if(HAVE_BIG_DECIMAL)
-			setXXX_setObject(s, psi, psq, type, BigDecimal.valueOf(72L), "java.math.BigDecimal", 1,
executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, Boolean.TRUE, "java.lang.Boolean", 2, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, new Integer(74), "java.lang.Integer", 3, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, new Long(79), "java.lang.Long", 4, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, new Float(76.3f), "java.lang.Float", 5, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, new Double(12.33d), "java.lang.Double", 6, executeBatchTests);
+			setXXX_setObject(s, psi, psq, type, BigDecimal.valueOf(72L), "java.math.BigDecimal", 1);
+		setXXX_setObject(s, psi, psq, type, Boolean.TRUE, "java.lang.Boolean", 2);
+		setXXX_setObject(s, psi, psq, type, new Integer(74), "java.lang.Integer", 3);
+		setXXX_setObject(s, psi, psq, type, new Long(79), "java.lang.Long", 4);
+		setXXX_setObject(s, psi, psq, type, new Float(76.3f), "java.lang.Float", 5);
+		setXXX_setObject(s, psi, psq, type, new Double(12.33d), "java.lang.Double", 6);
 
 		{
 		byte[] data = {0x32, 0x39};
-		setXXX_setObject(s, psi, psq, type, data, "byte[]", 7, executeBatchTests);
+		setXXX_setObject(s, psi, psq, type, data, "byte[]", 7);
 		}
 
 
-		setXXX_setObject(s, psi, psq, type, java.sql.Date.valueOf("2004-02-14"), "java.sql.Date",
8, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, java.sql.Time.valueOf("13:26:42"), "java.sql.Time",
9, executeBatchTests);
-		setXXX_setObject(s, psi, psq, type, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551"),
"java.sql.Timestamp", 10, executeBatchTests);
+		setXXX_setObject(s, psi, psq, type, java.sql.Date.valueOf("2004-02-14"), "java.sql.Date",
8);
+		setXXX_setObject(s, psi, psq, type, java.sql.Time.valueOf("13:26:42"), "java.sql.Time",
9);
+		setXXX_setObject(s, psi, psq, type, java.sql.Timestamp.valueOf("2004-02-23 17:14:24.097625551"),
"java.sql.Timestamp", 10);
 		s.getConnection().commit();
 
 		if (!isDB2jNet) {
@@ -2595,7 +2592,7 @@
 			rsc.next();
 			Blob tester = rsc.getBlob(1);
 			rsc.close();
-			setXXX_setObject(s, psi, psq, type, tester, "java.sql.Blob", 11, executeBatchTests);
+			setXXX_setObject(s, psi, psq, type, tester, "java.sql.Blob", 11);
 		}
 
 		{
@@ -2603,13 +2600,12 @@
 			rsc.next();
 			Clob tester = rsc.getClob(1);
 			rsc.close();
-			setXXX_setObject(s, psi, psq, type, tester, "java.sql.Clob", 12, executeBatchTests);
+			setXXX_setObject(s, psi, psq, type, tester, "java.sql.Clob", 12);
 		}
 		}
 	}
 
-	private static void setXXX_setObject(Statement s, PreparedStatement psi, PreparedStatement
psq, int type, Object value, String className, int b5o,
-			boolean executeBatchTests)
+	private static void setXXX_setObject(Statement s, PreparedStatement psi, PreparedStatement
psq, int type, Object value, String className, int b5o)
 		throws SQLException, java.io.IOException
 	{
 		{
@@ -2634,7 +2630,7 @@
 		}
 		judge_setObject(worked, sqleResult, b5o, type);
 		}
-		if (executeBatchTests) {
+		{
 			s.execute("DELETE FROM PM.TYPE_AS");
 
 			SQLException sqleResult = null;



Mime
View raw message