db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suavi Ali Demir <dem...@yahoo.com>
Subject RE: Shutdown and reconnection results in "No suitable Driver"
Date Fri, 25 Feb 2005 21:37:33 GMT
Well, since it says no suitable driver, maybe it is
sufficient to re-register the driver. Did you try a
Class.forName("drivername").newInstance() and maybe
take that instance and use
DriverManager.registerDriver(driver) ?

Regards,
Ali


--- Bernd Ruehlicke <BRuehlicke@lgc.com> wrote:
> Maybe the question is leading to a more general
> question.
> 
> Can I use the same Derby database instance from 2
> JVM's ?  The scenario
> would be a controlling JVM which one in a while need
> to connect to derby
> - than disconnect. While the (still running) first
> JVM has disconnected
> a second JVM will try to access the same Derby
> database - and releases
> the connection simply when the JVM ends, whereafter
> again the
> controlling JVM want to open a connection to this
> Derby instance.
> 
> I thought by doing the shutdown this was the way -
> but it seams that if
> you first have done a shutdown once - you are done
> for this JVM and need
> to restart the JVM to be able to establish a new
> frsh connection.
> 
> 
> B-) 
> 
> > -----Original Message-----
> > From: Bernd Ruehlicke [mailto:BRuehlicke@lgc.com] 
> > Sent: Friday, February 25, 2005 3:04 PM
> > To: Derby Discussion
> > Subject: Shutdown and reconnection results in "No
> suitable Driver"
> > 
> > Here a strange situation. I have a main JVM which
> has a Derby 
> > Embedded connection. It spinns off to call a
> script which 
> > again will make a Derby Connection. To allow this
> Embedded I 
> > have to disconnect from Derby in the first JVM. It
> turned out 
> > I had to use Shutdown in th efirsyt to let the
> second jvm 
> > allow to connect
> >  
> > // shutting down a database from your application 
> > DriverManager.getConnection(
> >     "jdbc:derby:;shutdown=true");
> >  
> > So far so good. Now when JVM number one want to
> reestablish 
> > it's connection via the usual Class.forName(...)
> ... 
> > DriverGetConnection(url,user,passw) 
> >  
> > I get
> >  
> > a java.sql.SQLException: No suitable Driver 
> >  
> >  
> > I have created a JUnit test which simply just
> Loops over a 
> > connection , a shutdown and a new connection - it
> fails with 
> > the 2. connection. see code snipled below. Trust
> me that the 
> > url is correct and that the first time it goes via
> the loop 
> > it connect correctly.
> >  
> >  
> > Any thoughts ?!!
> >  
> > B-)
> >  
> >    .....
> >          for(int tal=0;tal<10;tal=tal+1)
> >          {
> >              Class.forName(driver);
> >              System.out.println("Running for
> number : "+tal);
> >              System.out.println("Loaded the
> appropriate driver.");
> >                   
> >              _connection =
> DriverManager.getConnection(url + 
> > ";create=true", user, pass);
> >              
> >              if(tal<9)this.tearDown();
> >          }
> > 
> > ......
> >  
> >  
> > where tearDown() is
> >      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("TestDerby finished");
> >  
> >      }
> > 
> >  
> > 
> 


Mime
View raw message