• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL warnings driving me nuts  RSS feed

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok people. I'm using db2 and if I try to execute the statement:
Update t set i = 10 where i = 123
this row where i = 123 doesn't exist and I get the following warning: SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table. SQLSTATE=02000
So far...everything's fine. Now I try to catch this warning through jdbc. Here's my code:
import java.io.*;
import java.util.*;
import java.sql.*;
class PELoad {
static {
try {
} catch (Exception e) {
} //catch
} //static
public static void main(String args[]) {
try {
Connection con = DriverManager.getConnection("jdbc b2 ELoad");
Statement stmt = con.createStatement();
stmt.executeUpdate("Update t set i = 10 where i = 123");
SQLWarning warning = stmt.getWarnings();
if (warning != null) {
while (warning != null) {
System.out.println("Message: " + warning.getMessage());
System.out.println("SQLState: " + warning.getSQLState());
System.out.print("Vendor error code: ");
warning = warning.getNextWarning();
} //while
} //main
} catch(Exception e) {System.out.println(e);}
} //main
} //PEload
compiles fine...java program...computer starts thinking...sbam! nothing happens, not even a little error message. Any idea what I'm doing wrong?
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if you are testing the Warning thing or if you want to check whether the row was really updated. In the latter case, Statement.executeUpdate(...) should return an int, in your case it should be zero and you could go from there.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!