Surround with Try/Catch

Surround with Try/Catch is another coding enhancement provided by JBuilder. Surround with Try/Catch is accessible from the context-sensitive pop-up menu during code editing.

JBuilder detects all exceptions for a highlighted set of lines. After detecting the possible exceptions, JBuilder places try and catch statements around the highlighted lines.

Listing 7.10 displays sample code that makes a call to the database. Most database calls return a SQLException if there are any problems.

Listing 7.10. Sample Database Code
 stmtCommand.executeUpdate("insert into JDBCSample values('Michael', 45)"); stmtCommand.executeUpdate("insert into JDBCSample values('Jeff', 22)"); stmtCommand.executeUpdate("insert into JDBCSample values('Saleem', ...

Get Borland® JBuilder™ Developer’s Guide 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.