db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Bortnovskiy <pbortnovs...@jefferies.com>
Subject RE: Shutting down in-memory Derby gracefully
Date Tue, 17 Jan 2012 02:14:19 GMT
Hello, all

can someone please also shed light on the following:

In addition to the problems described in the previous email (below), I also get intermittent
" Database 'memory:test' not found" errors while shutting down Derby:

Error while shutting down:
java.sql.SQLException: Database 'memory:test' not found.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)          
                                                            at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:207)
Caused by: java.sql.SQLException: Database 'memory:test' not found.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
        ... 21 more

This error doesn't happen all the time, it's intermittent and I suspect that it might have
be somehow connected to other problems I've been having trying to shutdown in-memory Derby
DB gracefully.

Can someone please help me understand what's causing this particular problem?

My code that's shutting down Derby is quite simple, and oddly it works most of the times,
but sometimes it throws this " Database 'memory:test' not found " error!

Here is the excerpt of my shutdown code:

    private static final String DB_DROP_URL = "jdbc:derby:memory:%DB_NAME%;drop=true";
    private static final String DB_SHUTDOWN_URL = "jdbc:derby:;shutdown=true";

    private static class ShutdownAction {
        final private String m_url;
        final private int m_errorCode;
        final private String m_sqlState;

        private ShutdownAction(final String url, final int errorCode, final String sqlState)
{
            m_url = url;
            m_errorCode = errorCode;
            m_sqlState = sqlState;
        }

        private void doAction(final String dbName) {
            final String url = m_url.replace("%DB_NAME%", dbName);
            logger.info("Executing Derby Shutdown Command: " + url);
            try {
                DriverManager.getConnection(url);
            } catch (SQLException e) {
                if ((e.getErrorCode() != m_errorCode) || (!m_sqlState.equals(e.getSQLState())))
{
                    logger.error("Error while shutting down:", e);
                }
            }
        }
    }

    private static final ShutdownAction[] ACTIONS = {
            new ShutdownAction(DB_DROP_URL, 45000, "08006"),
            new ShutdownAction(DB_SHUTDOWN_URL, 50000, "XJ015")
    };

    private String m_dbName;
    private String m_dbCreateURL;

    private NetworkServerControlPinger m_derbyServerControl;

    @Override
    final public void shutdown() {
        for (final ShutdownAction action : ACTIONS) {
            action.doAction(m_dbName);
        }

        m_derbyServerControl.shutdown();
    }



-----Original Message-----
From: Pavel Bortnovskiy [mailto:pbortnovskiy@jefferies.com]
Sent: Friday, January 13, 2012 10:01 AM
To: Derby Discussion
Subject: RE: Shutting down in-memory Derby gracefully

Hello, Bryan:

Thank you for your prompt response. I will report it as per guidelines.

Would you be able to suggest anything that I could do in the meantime?
We have watchdog processes monitoring error files and when the error files get populated with
these messages, the watchdog raises all kinds of alarms.
This is more than just a nuisance, as it's causing havoc in some cases.

Thank you,
Pavel.

-----Original Message-----
From: Bryan Pendleton [mailto:bpendleton.derby@gmail.com]
Sent: Friday, January 13, 2012 9:58 AM
To: Derby Discussion
Subject: Re: Shutting down in-memory Derby gracefully

> While our application is shutting down, it is possible that some of
> its components may continue execution or even begin execution of the
> queries on the in-memory Derby DB. In such situation, Derby starts throwing all kinds
of exceptions, including a Null Pointer Exception (pls see excerpt from our log below).

That looks like a bug to me, and worthy of reporting to the Derby developers.

http://db.apache.org/derby/DerbyBugGuidelines.html

thanks,

bryan


Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email,
including any attachments, are confidential to the ordinary user of the email address to which
it was addressed. If you are not the addressee of this email you may not copy, forward, disclose
or otherwise use it or any part of it in any form whatsoever. This email may be produced at
the request of regulators or in connection with civil litigation. Jefferies accepts no liability
for any errors or omissions arising as a result of transmission. Use by other than intended
recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International
Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames
Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the
Financial Services Authority.
Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email,
including any attachments, are confidential to the ordinary user of the email address to which
it was addressed. If you are not the addressee of this email you may not copy, forward, disclose
or otherwise use it or any part of it in any form whatsoever. This email may be produced at
the request of regulators or in connection with civil litigation. Jefferies accepts no liability
for any errors or omissions arising as a result of transmission. Use by other than intended
recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International
Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames
Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the
Financial Services Authority.

Mime
View raw message