Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsequent calls to Connection.close() should not throw an error and be ignored #32

Open
gilius38 opened this issue Sep 30, 2014 · 0 comments

Comments

@gilius38
Copy link
Contributor

According to jdbc spec: "Calling the method close on a Connection object that is already closed is a no-op."
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#close()

This simple code throws an error:

    Class.forName("org.drizzle.jdbc.DrizzleDriver").newInstance();
    Connection conn = null;
    {
        conn = DriverManager.getConnection("jdbc:mysql:thin://" + HOST + ":"
                + PORT + "/" + DB, USER, PASS);
    }
    conn.close();
    conn.close();

Proposed fix in DrizzleConnection:

    public void close() throws SQLException {
        if (isClosed())
            return;
        ...

Note: I was unable to tell whether the timeoutExecutor could be running while protocol.isClosed() is true. It might be worth trying to this.timeoutExecutor.shutdown(); in any case

StephG38 added a commit to StephG38/DrizzleJDBC that referenced this issue Sep 30, 2014
krummas added a commit that referenced this issue Dec 29, 2014
 Fixes issue #32 : if connection is already closed, do nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant