view src/main/java/nl/cwi/monetdb/embedded/env/AbstractConnectionResult.java @ 51:c592d8a72627 embedded

More defensive approach for tables. Only the table name and schema are cached.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Wed, 16 Nov 2016 21:21:26 +0100 (2016-11-16)
parents 3a19ebf83af6
children 80bae18085f0
line wrap: on
line source
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0.  If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Copyright 2016 MonetDB B.V.
 */

package nl.cwi.monetdb.embedded.env;

import java.io.Closeable;

/**
 * The base class for a pending statement to a connection.
 *
 * @author <a href="mailto:pedro.ferreira@monetdbsolutions.com">Pedro Ferreira</a>
 */
public abstract class AbstractConnectionResult implements Closeable {

    /**
     * The corresponding connection of this result.
     */
    private final MonetDBEmbeddedConnection connection;

    protected AbstractConnectionResult(MonetDBEmbeddedConnection connection) { this.connection = connection; }

    /**
     * Get the corresponding connection to this statement result.
     *
     * @return A MonetDBEmbeddedConnection instance
     */
    public MonetDBEmbeddedConnection getConnection() { return connection; }

    protected long getConnectionPointer() { return connection.connectionPointer; }

    /**
     * To be called by the connection when is closing.
     */
    protected abstract void closeImplementation();

    @Override
    public void close() {
        this.closeImplementation();
        this.connection.removeQueryResult(this);
    }
}