diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-09-26 13:14:05 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-09-26 13:14:05 -0230 |
commit | 6cb3c945b8d7acee729a5ae0ffc311d413727973 (patch) | |
tree | cd9f00d53d6d3bbb08f46fea546267bc9020f142 /java/demo/Database/library/BookI.java | |
parent | ICE-3692 library database demo doesn't throw object not exist sometimes (diff) | |
download | ice-6cb3c945b8d7acee729a5ae0ffc311d413727973.tar.bz2 ice-6cb3c945b8d7acee729a5ae0ffc311d413727973.tar.xz ice-6cb3c945b8d7acee729a5ae0ffc311d413727973.zip |
Slightly improved fix for ICE-3692
Diffstat (limited to 'java/demo/Database/library/BookI.java')
-rw-r--r-- | java/demo/Database/library/BookI.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/java/demo/Database/library/BookI.java b/java/demo/Database/library/BookI.java index 68daf4340d7..2c0ab982339 100644 --- a/java/demo/Database/library/BookI.java +++ b/java/demo/Database/library/BookI.java @@ -78,20 +78,14 @@ class BookI extends _BookDisp try { - // First make sure the book still exists. - java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); - stmt.setInt(1, id); - java.sql.ResultSet rs = stmt.executeQuery(); - if(!rs.next()) - { - throw new Ice.ObjectNotExistException(); - } - - stmt = context.prepareStatement("UPDATE books SET title = ? WHERE id = ?"); + java.sql.PreparedStatement stmt = context.prepareStatement("UPDATE books SET title = ? WHERE id = ?"); stmt.setString(1, title); stmt.setInt(2, id); int count = stmt.executeUpdate(); - assert count == 1; + if(count == 0) + { + throw new Ice.ObjectNotExistException(); + } } catch(java.sql.SQLException e) { @@ -111,7 +105,7 @@ class BookI extends _BookDisp try { - // First make sure the book still exists. + // First make sure the book still exists java.sql.PreparedStatement stmt = context.prepareStatement("SELECT * FROM books WHERE id = ?"); stmt.setInt(1, id); java.sql.ResultSet rs = stmt.executeQuery(); @@ -134,7 +128,7 @@ class BookI extends _BookDisp Integer authid; stmt = context.prepareStatement("SELECT * FROM authors WHERE name = ?"); stmt.setString(1, author); - java.sql.ResultSet rs = stmt.executeQuery(); + rs = stmt.executeQuery(); if(rs.next()) { // If there is a result, then the database |