import java.sql.*;

public class DatabaseStreams {

    public static void method() {

        Connection connection = null;
        Statement statement = null;

        try {
            connection = DriverManager.getConnection("blah");
            statement = connection.createStatement();
            // do something with statement
        }
        catch (SQLException e) {
            System.err.println("Error: " + e);
        }
        finally {
            if (statement != null) {
                try {
                    statement.close();
                }
                catch (SQLException e) {
                    System.err.println("Error closing statement: " + e);
                }
            }
            if (connection != null) {
                try {
                    connection.close();
                }
                catch (SQLException e) {
                    System.err.println("Error closing connection: " + e);
                }
            }
        }
    }
}


Check for closing database streams.
Check for closing database streams.


git-svn-id: e7d6bde23f017c9ff4efd468d79d66def666766b@2731 eae3c2d3-9b19-0410-a86e-396b6ccb6ab3
