[hibernate-commits] Hibernate SVN: r11340 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Mar 23 08:51:55 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-03-23 08:51:55 -0400 (Fri, 23 Mar 2007)
New Revision: 11340

Modified:
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
Log:
db2 testsuite

Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java	2007-03-23 12:51:38 UTC (rev 11339)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/exception/SQLExceptionConversionTest.java	2007-03-23 12:51:55 UTC (rev 11340)
@@ -49,12 +49,12 @@
 
 		// Attempt to insert some bad values into the T_MEMBERSHIP table that should
 		// result in a constraint violation
+		PreparedStatement ps = null;
 		try {
-			PreparedStatement ps = connection.prepareStatement("INSERT INTO T_MEMBERSHIP (user_id, group_id) VALUES (?, ?)");
+			ps = connection.prepareStatement("INSERT INTO T_MEMBERSHIP (user_id, group_id) VALUES (?, ?)");
 			ps.setLong(1, 52134241);    // Non-existent user_id
 			ps.setLong(2, 5342);        // Non-existent group_id
 			ps.executeUpdate();
-			ps.close();
 
 			fail("INSERT should have failed");
 		}
@@ -65,6 +65,16 @@
 			ConstraintViolationException ex = (ConstraintViolationException) jdbcException;
 			System.out.println("Violated constraint name: " + ex.getConstraintName());
 		}
+		finally {
+			if ( ps != null ) {
+				try {
+					ps.close();
+				}
+				catch( Throwable ignore ) {
+					// ignore...
+				}
+			}
+		}
 
 		session.close();
 	}
@@ -76,16 +86,26 @@
 		Connection connection = session.connection();
 
         // prepare a query against a non-existent table
+		PreparedStatement ps = null;
 		try {
-			PreparedStatement ps = connection.prepareStatement("SELECT user_id, user_name FROM tbl_user");
+			ps = connection.prepareStatement("SELECT user_id, user_name FROM tbl_user");
 			ps.executeQuery();
-			ps.close();
 
 			fail("SQL compilation should have failed");
 		}
 		catch( SQLException sqle ) {
 			assertEquals( "Bad conversion [" + sqle.getMessage() + "]", SQLGrammarException.class, converter.convert(sqle, null, null).getClass() );
 		}
+		finally {
+			if ( ps != null ) {
+				try {
+					ps.close();
+				}
+				catch( Throwable ignore ) {
+					// ignore...
+				}
+			}
+		}
 
 		session.close();
 	}




More information about the hibernate-commits mailing list