What is the suitable way to close the database connection in Java?

后端 未结 7 1761
盖世英雄少女心
盖世英雄少女心 2020-12-20 04:15

I tried to close the DB connection.But had a bit of confusion, say

ResultSet rs = null 

Whether I have to it close by

rs.c         


        
7条回答
  •  我在风中等你
    2020-12-20 04:49

    The jdbc api tells us that closing the connection will close result sets and statements. Closing statements will close the result set. But I always close every result set and every statement myself because I ran into problems not doing so. Just use the close method provided by you result set, statement and connection.

提交回复
热议问题