How can I check whether a database connection is closed or open using java?

NewBee Developer picture NewBee Developer · Mar 16, 2015 · Viewed 8.4k times · Source
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=Signing_Utility.mdb;";
Connection con = DriverManager.getConnection(database, "", "");
Statement s = con.createStatement();

Answer

Umberto Raimondi picture Umberto Raimondi · Mar 16, 2015

Is con.isClosed() good enough? You can check the official documentation of the Connection class here, the oracle documentation is the first place to go when you want to learn more about standard Java classes.