Java JDBC connection status

前端 未结 6 1265
太阳男子
太阳男子 2020-12-02 19:52

I am (successfully) connecting to a database using the following:

java.sql.Connection connect = DriverManager.getConnection(
  \"jdbc:mysql://localhost/some_         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 20:27

    Use Connection.isClosed() function.

    The JavaDoc states:

    Retrieves whether this Connection object has been closed. A connection is closed if the method close has been called on it or if certain fatal errors have occurred. This method is guaranteed to return true only when it is called after the method Connection.close has been called.

提交回复
热议问题