Client 4—A More Robust Query Processor

In client4, I'll show you how to handle three different problems that you'll eventually find in the client3 application:

  • If the user executes a command that fails for some reason (syntax error, table doesn't exist, and so on), client3 throws an unhandled exception and the program gets so embarrassed that it terminates.

  • If the user executes a command other than SELECT, the command completes, but the application throws another one of those embarrassing unhandled exceptions.

  • If the user clicks the Commit button and something goes wrong during the Update(), some changes may be recorded to the database and others may not.

It's easy to replicate the first problem—just type in a nonsense command and press Ctrl+Enter. ...

Get PostgreSQL, Second Edition 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.