• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

SQL warnings driving me nuts

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic