The catch block catches any SQLException's that occur, print an error message, then throw the exception. String selectStatement = "SELECT contact_email FROM store WHERE contact_id = ?" Ĭonnection = ConnectionPool.getConnection() ĭoSelect = connection.prepareStatement(selectStatement) ĬeeConnection(connection) Public String getContactEmail(int contactNumber) Java/JDBC try/catch/finally exception FAQ: Can you show me a decent example of how to catch a JDBC exception in a try/catch/finally block?īeauty is in the eye of the beholder, but here's a JDBC example showing some Java code that uses a try/catch/finally block with a Java JDBC query:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |