Search code examples
javajdbcconnectivityjdbc-odbc

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


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();

Solution

  • 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.