db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Flavio Palumbo" <f.palu...@silmasoftware.com>
Subject R: connection strange behavior
Date Thu, 20 Jul 2006 13:44:42 GMT
Hi,

thanks everybody for the suggestions provided ;-))

Now I try to explane my goal :

- I have an application shared in a local network environment (one jar file
where every client in the network can double
  click and start it in a new jvm)
- when the application starts, I'd like to start (automatically) the derby
network server
- every client opens a new connection to the server
- when the client finishes its work, it closes its own connection, shut down
its instance of the application and closes
  its jvm
- the last client closes the server
- note that the shared derby DB is in a network shared directory

to achieve the aim explaned above I wrote a test case where I do something
different : every time the application starts,
it starts a new instance of the network server and a new connection. I did
this cause I don't know how to start the network server only once (when the
first client starts the application) and also don't know how to be informed
when the last
client closes the application.
This kind of test seems to work ; if I open the application in two different
shells of my PC (two jvm) I can read and write into the same table of the
same db, thus it seems to be shared as I desire.
But following the tests I encountered some impredictable errors (not always
the same error, data seems to be lost, strange exceptions ...) making me
think maybe this is not the right way :-((

Thanks for any suggestion
Flavio

> -----Messaggio originale-----
> Da: Kristian.Waagan@Sun.COM [mailto:Kristian.Waagan@Sun.COM]
> Inviato: mercoledì 19 luglio 2006 18.31
> A: Derby Discussion
> Oggetto: Re: connection strange behavior
>
>
> Flavio Palumbo wrote:
> > Hi all,
> >
> > I wrote a little class, derived from NsSample.java found in
> D:\db-derby-10.1.2.1-bin\demo\nserverdemo,
> > to start an embedded server and use it with an embedded client
> (no embedded
> > driver but org.apache.derby.jdbc.ClientDriver) fron within a
> java application,
> > all in the same JVM.
> >
> > The first strange thing I found is that if I try to access the data with
> > the ij utility while the application is running, I receive a
> messagge like
> > this :
> >
> > ERROR XJ040: Failed to start database 'c:\ESQueryProd\derbyDB',
> see the next
> > exception for details.
> > ERROR XSDB6: Another instance of Derby may have already booted
> the database
> > C:\ESQueryProd\derbyDB.
> >
> > Obviously, when I close the application everything goes fine.
> >
> > I thought that network server shares connection and data, but
> it seems not
> > to be true.
> >
> > How can I do that ?
>
> Hello Flavio,
>
> If I understand you correctly, what you are trying to do should be
> possible. To make sure we are on the same page here, I have written a
> small application that creates two connections to a database:
>   1) I instruct Derby to start the NetworkServer by setting the property
> derby.drda.startNetworkServer = true.
>   2) The first connection creates the database 'testDB' using the
> embedded driver. The network server is also started now.
>   3) The second connection to 'testDB' is created by using the client
> driver.
>   4) I can connect to the same database using ij by specifying the
>      following command (from ij):
>      > connect 'jdbc:derby://localhost/testDB';
>
> Does this demonstrate what you are trying to to?
> You need to have the Derby jars in your classpath when running the
> application (and ij). Which exactly depends on your Derby version.
>
> I think there are variations on how to do this, and I'm sure people will
> let us know if there are easier/better ways to do it.
>
>
> If you have further questions, we'll try to answer them :)
>
>
>
> Regards,
> --
> Kristian
>
> >
> > I found the same behavior starting the application twice from newtwork :
> > the first application starts correctly, the second freezes
> until I shut down
> > the first.
> >
> > Thanks for any suggetion
> >
> > Flavio
> >
> > PS I run with jvm 1.4.2_09 with win XP sp2 and derby 10.1.2.1
> >
> >
>
>


-----------------------------------------------------------
Il presente messaggio non costituisce un impegno contrattuale tra SILMA S.r.l. ed il destinatario.
Le opinioni ivi espresse sono quelle dell'autore.
SILMA S.r.l. non assume alcuna responsabilita riguardo al contenuto del presente messaggio.
Il messaggio è destinato esclusivamente al destinatario.
Il contenuto e gli allegati sono da considerarsi di natura confidenziale

Nel caso abbiate ricevuto il presente messaggio per errore siete pregati di comunicarlo
alla casella segreteria@silmasoftware.com.
Mime
View raw message