This is "as designed". I found other places where the usual way of coding this is like

         try
         {
             // Now try to disconnect
             _connection.close();
             _connection = null;
            _logger.info("Closed connection");

             /*
                In embedded mode, an application should shut down Derby.
                If the application fails to shut down Derby explicitly,
                the Derby does not perform a checkpoint when the JVM shuts down, which means
                that the next connection will be slower.
                Explicitly shutting down Derby with the URL is preferred.
                This style of shutdown will always throw an "exception".
              */
             boolean gotSQLExc = false;

             try
             {
                 DriverManager.getConnection("jdbc:derby:;shutdown=true");
             }
             catch(SQLException se)
             {
                 gotSQLExc = true;
             }

             if(!gotSQLExc)
             {
                 _logger.fine("Database did not shut down normally");
             }
             else
             {
                 _logger.fine("Database shut down normally");
             }
         }
         catch (Throwable e)
         {
             _logger.fine("exception thrown:"+e.getMessage());
                 e.printStackTrace();
         }



On Feb 11, 2008 3:24 PM, Henrik Frisk <frisk.h@gmail.com> wrote:
Hi,

I'm just starting to familiarize myself with the Derby Java API and I keep getting an Exception when I'm trying to shut down an embedded server using the following call:

DriverManager.getConnection("jdbc:derby:;shutdown=true");

Now, I was just looking at the SimpleNetworkServerSample demo that comes with the db-derby download and saw he following:

            try
            {
                // shutdown Derby Network Server
                DriverManager.getConnection("jdbc:derby:;shutdown=true");
            }
            catch(SQLException se)
            {
                //ignore se
            }

The comment //ignore se made me think maybe it's normal it throws an Exception. If not, what would be the right way to shut down the server? I'm starting the server with

System.setProperty("derby.drda.startNetworkServer","true");

and run it with the embedded driver. The db will run strictly on localhost and I'm in control of the clients connecting to it.

Any hints would be greatly appreciated,

Henrik