Java 7 Automatic Resource Management JDBC (try-with-resources statement)

前端 未结 3 1067
长发绾君心
长发绾君心 2020-12-01 00:39

How to integrate the common JDBC idiom of creating/receiving a connection, querying the database and possibly processing the results with Java 7\'s automatic resource manage

3条回答
  •  臣服心动
    2020-12-01 01:37

    IMO, declaring Connection and PreparedStatement outside try-catch is the best way available in this case.

提交回复
热议问题