db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Ruehlicke" <BRuehli...@lgc.com>
Subject RE: derby jdbc load driver
Date Tue, 09 Aug 2005 21:51:44 GMT
I can confirm this.

In additon shut it down gracefully alla the code below which I found in
some doc while fighting with the forgotten .newInstance()



     protected void tearDown()
     {
         try
         {
             // Now try to disconnect
             _connection.close();
             _connection = null;
             System.out.println("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();
         }

         System.out.println("Derby finished");

     }


B-)

 

> -----Original Message-----
> From: Satheesh Bandaram [mailto:satheesh@Sourcery.Org] 
> Sent: Tuesday, August 09, 2005 4:32 PM
> To: Derby Discussion
> Subject: Re: derby jdbc load driver
> 
> I think Derby recommends using .newInstance() to load JDBC 
> drivers... In fact, it is required if you plan to shutdown 
> and reboot databases on the same thread/VM for Derby. Take a 
> look at the javadoc for EmbeddedDriver.
> 
> http://db.apache.org/derby/javadoc/engine/org/apache/derby/jdb
> c/EmbeddedDriver.html
> 
> Satheesh
> 
> Oyvind.Bakksjo@Sun.COM wrote: 
> 
> 	Bogdan Mihaila wrote: 
> 	
> 
> 		Hello! 
> 		  
> 		I'm trying to load the embedded derby driver, 
> like this: 
> 		  
> 		
> Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); 
> 		
> 
> 
> 	As Rajesh pointed out, the problem is most likely the 
> CLASSPATH. If you still have problems, please send the 
> complete exception, including stack trace, as this helps to 
> figure out the problem. 
> 	
> 	By the way, you don't need the '.newInstance()' part - 
> simply loading the driver class will set up the Derby system. 
> 	
> 	
> 
> ________________________________
> 
> This e-mail, including any attached files, may contain 
> confidential and privileged information for the sole use of 
> the intended recipient. Any review, use, distribution, or 
> disclosure by others is strictly prohibited. If you are not 
> the intended recipient (or authorized to receive information 
> for the intended recipient), please contact the sender by 
> reply e-mail and delete all copies of this message.
> 
> 
----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.

Mime
View raw message