db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1177475 - in /db/derby/code/trunk: ./ java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
Date Fri, 30 Sep 2011 01:29:39 GMT
Author: myrnavl
Date: Fri Sep 30 01:29:39 2011
New Revision: 1177475

URL: http://svn.apache.org/viewvc?rev=1177475&view=rev
Log:
DERBY-5421;  NullPointerException during system.nstest.utils.Dbutil.update_one_row
	merging 1177446 from 10.8 to trunk

Modified:
    db/derby/code/trunk/   (props changed)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java

Propchange: db/derby/code/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 30 01:29:39 2011
@@ -1,2 +1,3 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
+/db/derby/code/branches/10.8:1177474
 /db/derby/code/trunk:1063809

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java?rev=1177475&r1=1177474&r2=1177475&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
Fri Sep 30 01:29:39 2011
@@ -230,74 +230,76 @@ public class TesterObject {
 			s.close();
 		}
 
-		// Now work over the returned ResultSet and keep track of number of rows
-		// returned
-		// We execute the getXXX methods on each of the selected columns so that
-		// data flow out
-		// from the network server is also tested.
-		try {
-			while (rSet.next()) {
-				// get value of column id
-				int id1 = rSet.getInt(1);
-
-				// get value of column t_char
-				String str1 = rSet.getString(2);
-
-				// get value of column t_date
-				Date dt = rSet.getDate(3);
-
-				// get value of column t_decimal
-				double doub1 = rSet.getDouble(4);
-
-				// get value of column t_decimal_nn
-				double doub2 = rSet.getDouble(5);
-
-				// get value of column t_double
-				double doub3 = rSet.getDouble(6);
-
-				// get value of column t_float
-				float flt1 = rSet.getFloat(7);
-
-				// get value of column t_int
-				int id2 = rSet.getInt(8);
-
-				// get value of column t_longint
-				long lg1 = rSet.getLong(9);
-
-				// get value of column t_numeric_large
-				double doub4 = rSet.getDouble(10);
-
-				// get value of column t_real
-				float flt2 = rSet.getFloat(11);
-
-				// get value of column t_smallint
-				int id3 = rSet.getInt(12);
-
-				// get value of column t_time
-				Time tm = rSet.getTime(13);
-
-				// get value of column t_timestamp
-				Timestamp tstmp = rSet.getTimestamp(14);
-
-				// get value of column t_varchar
-				String str2 = rSet.getString(15);
-
-				// get value of column serialkey
-				long lg2 = rSet.getLong(16);
-
-				numRowsSelected++;
-			}
-			NsTest.addStats(NsTest.SELECT, 1);
-			System.out.println(this.thread_id + " selected " + numRowsSelected
-					+ " rows");
-		} catch (Exception e) {
-			System.out
-			.println("FAIL: doSelectOperation() had problems working over the ResultSet");
-			NsTest.addStats(NsTest.FAILED_SELECT, 1);
-			printException("processing ResultSet during row data retrieval", e);
-			rSet.close();
-			s.close();
-			System.out.println("Closed the select statement");
+		if (rSet != null) {
+		    // Now work over the returned ResultSet and keep track of number of rows
+		    // returned
+		    // We execute the getXXX methods on each of the selected columns so that
+		    // data flow out
+		    // from the network server is also tested.
+		    try {
+		        while (rSet.next()) {
+		            // get value of column id
+		            int id1 = rSet.getInt(1);
+
+		            // get value of column t_char
+		            String str1 = rSet.getString(2);
+
+		            // get value of column t_date
+		            Date dt = rSet.getDate(3);
+
+		            // get value of column t_decimal
+		            double doub1 = rSet.getDouble(4);
+
+		            // get value of column t_decimal_nn
+		            double doub2 = rSet.getDouble(5);
+
+		            // get value of column t_double
+		            double doub3 = rSet.getDouble(6);
+
+		            // get value of column t_float
+		            float flt1 = rSet.getFloat(7);
+
+		            // get value of column t_int
+		            int id2 = rSet.getInt(8);
+
+		            // get value of column t_longint
+		            long lg1 = rSet.getLong(9);
+
+		            // get value of column t_numeric_large
+		            double doub4 = rSet.getDouble(10);
+
+		            // get value of column t_real
+		            float flt2 = rSet.getFloat(11);
+
+		            // get value of column t_smallint
+		            int id3 = rSet.getInt(12);
+
+		            // get value of column t_time
+		            Time tm = rSet.getTime(13);
+
+		            // get value of column t_timestamp
+		            Timestamp tstmp = rSet.getTimestamp(14);
+
+		            // get value of column t_varchar
+		            String str2 = rSet.getString(15);
+
+		            // get value of column serialkey
+		            long lg2 = rSet.getLong(16);
+
+		            numRowsSelected++;
+		        }
+		        NsTest.addStats(NsTest.SELECT, 1);
+		        System.out.println(this.thread_id + " selected " + numRowsSelected
+		                + " rows");
+		    } catch (Exception e) {
+		        System.out
+		        .println("FAIL: doSelectOperation() had problems working over the ResultSet");
+		        NsTest.addStats(NsTest.FAILED_SELECT, 1);
+		        printException("processing ResultSet during row data retrieval", e);
+		        rSet.close();
+		        s.close();
+		        System.out.println("Closed the select statement");
+		    }
 		}
 
 		// close the ResultSet and statement and release it's resources.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java?rev=1177475&r1=1177474&r2=1177475&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
Fri Sep 30 01:29:39 2011
@@ -226,16 +226,7 @@ public class DbUtil {
 			// ps.close();
 		}
 		
-		if (ps != null) {
-			try {
-				ps.close();
-				
-			} catch (Exception e) {
-				printException(
-						"closing insert stmt in dbUtil when there was a problem creating it",
-						e);
-			}
-		}
+	
 		return rowsAdded;
 	}
 	
@@ -256,8 +247,6 @@ public class DbUtil {
 		if (skey == 0) { // means we did not find a row
 			System.out.println(thread_id
 					+ " could not find a row to update or there was an error.");
-			if (ps2 != null)
-				ps2.close();
 			return rowsUpdated;
 		}
 		
@@ -272,7 +261,6 @@ public class DbUtil {
 					+ " = ? " + " where serialkey = " + skey);
 			
 		} catch (Exception e) {
-			ps2.close();
 			printException(
 					"closing update prepared stmt in dbUtil.update_one_row() ",
 					e);
@@ -385,7 +373,6 @@ public class DbUtil {
 					+ " " + sqe.getMessage());
 			sqe.printStackTrace();
 		} catch (Exception e) {
-			ps2.close();
 			printException("Error in update_one_row()", e);
 			e.printStackTrace();
 		} finally {
@@ -400,14 +387,7 @@ public class DbUtil {
 			System.out
 			.println(thread_id + " update failed, no such row exists");
 		
-		if (ps2 != null) {
-			try {
-				ps2.close();
-				
-			} catch (Exception e) {
-				printException("closing update stmt after work is done", e);
-			}
-		}
+	
 		return rowsUpdated;
 	}
 	
@@ -432,8 +412,6 @@ public class DbUtil {
 			System.out
 			.println("Unexpected error preparing the statement in delete_one()");
 			printException("delete_one_row prepare ", e);
-			if (ps != null)
-				ps.close();
 			return rowsDeleted;
 		}
 		
@@ -443,7 +421,6 @@ public class DbUtil {
 		if (skey == 0) { // means we did not find a row
 			System.out.println(thread_id
 					+ " could not find a row to delete or there was an error.");
-			ps.close();
 			return rowsDeleted;
 		}
 		
@@ -453,7 +430,6 @@ public class DbUtil {
 		} catch (Exception e) {
 			System.out
 			.println("Error in delete_one(): either with setLong() or executeUpdate");
-			ps.close();
 			printException("failure to execute delete stmt", e);
 		} finally {
 			conn
@@ -468,16 +444,6 @@ public class DbUtil {
 			System.out.println(thread_id + " delete for serialkey " + skey
 					+ " failed, no such row exists.");
 		
-		if (ps != null) {
-			try {
-				ps.close();
-			} catch (Exception e) {
-				System.out
-				.println("Error in closing prepared statement of delete_one()");
-				printException("failure to close delete stmt after work done",
-						e);
-			}
-		}
 		return rowsDeleted;
 	}// end of method delete_one()
 	
@@ -499,8 +465,6 @@ public class DbUtil {
 			ps = conn
 			.prepareStatement("select max(serialkey) from nstesttab where serialkey > ?");
 		} catch (Exception e) {
-			if (ps != null)
-				ps.close();
 			System.out
 			.println("Unexpected error creating the select prepared statement in pick_one()");
 			printException("failure to prepare select stmt in pick_one()", e);
@@ -543,22 +507,11 @@ public class DbUtil {
 			sqe.printStackTrace();
 		}
 		
-		if (ps != null) {
-			try {
-				ps.close();
-				
-			} catch (Exception e) {
-				System.out
-				.println("Error in closing prepared statement of pick_one()");
-				printException(
-						"failure closing select stmt in pick_one after work is done",
-						e);
-			}
-		}
+	
 		
 		return rowToReturn;
 		
-	}// end of method pick_one(...)
+	}//of method pick_one(...)
 	
 	// ** This method abstracts exception message printing for all exception
 	// messages. You may want to change



Mime
View raw message