SQLWarnings Versus SQLExceptions

Apache Derby can generate warnings in certain circumstances. A warning is generated if, for example, you try to connect to a database with the create attribute set to true, but the database already exists. Aggregates such as SUM() also raise a warning if null values are encountered during the evaluation. A warning will also being raised if an UPDATE or a DELETE statement affects no rows.

The following code uses a catch statement to capture any errors that occur during the execution of an UPDATE statement.

 try { conn = DriverManager.getConnection("jdbc:derby:YMLD"); s = conn.createStatement(); s.execute("UPDATE PRODUCTIONS SET PRODUCTION_NO = 10 WHERE PRODUCTION_NO = 0"); s.close(); } catch (SQLException se) { ...

Get Apache Derby—Off to the Races: Includes Details of IBM® Cloudscape™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.