Java Example Step 4: Closing the connection

Previous Next

Here is an example code fragment that shows how to close a database connection:

If (c != null)

{

    try

    {

        c.commit();

        c.close();

    }

    catch (SQLException e)

    {

        System.err.println("Close connection failed, " + e);

    }

}