db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: R: R: connection strange behavior
Date Tue, 01 Aug 2006 09:19:48 GMT
Flavio Palumbo wrote:
> Hi Stanley,
> 
> thanks for your responses ;-))
> 
> I looked the links you provided but I think my scenario is different.

I still don't quite understand the scenario.

Let's say there are 3 workstations (A, B and C) and one server (X).
I think you have a directory/disk on X that is shared between all 
workstations.

If you want to access a shared database from A, B and C at the same 
time, the most common solution would be to start the Derby network 
server on X, and have the applications on the workstations connect with 
the client driver (org.apache.derby.jdbc.ClientDriver).
This would require some management of server X, including 
starting/stopping the Derby network server when the machine is 
started/shutdown. The Derby network server would always be running as 
long as X is running.

*If* Derby were able to operate efficiently and correct when the 
database files are stored on a network drive, you would have to handle 
the logic of determining if and where the Derby network server is 
started. Doing this might require knowledge of all possible clients, a 
well-known location to post this information, or maybe a peer-to-peer 
architecture.


Maybe I'm a bit dense, but can you please explain why the centralized 
server approach won't work for you?

> 
> I wrote a stand alone application (like a VB .exe, not WEB) that is shared
> on a local network because the directory where the jars resides is shared
> for all the network users ; inside this directory is defined a derby
> database with 2 user tables, and I'd like that the access to these tables
> was shared for all the users that concurrently run the application.
> 
> The first time I tried to use the embedded driver, but this way doesn't
> share the database ; thus I tried to implement the network server making it
> start every time a user starts the application but in this way I found the
> problem mentioned in earlier mails.
> 
> I think a right way could be start the server once, in a separate jvm, when
> the first time the application is called and then let it up and running
> until the PC is shut down.
> 
> What you think about this ??

Here I'm confused again. Do you want to share data between multiple 
machines, or only between multiple applications on a single machine?

> 
> Another problem is that I don't know how start the server from inside the
> application in a separate jvm.
> 
> Could you give some other hints or code snippet ??

You could check if you can connect on specified port. If not, you assume 
the server is down, and that you are responsible for starting it. I'm 
sure someone know how to start the server as a separate process/JVM, but 
let us first make sure that is what you want to do :)



Regards,
-- 
Kristian

> 
> Thanks a lot
> Flavio
> 
> 
>> -----Messaggio originale-----
>> Da: Stanley Bradbury [mailto:Stan.Bradbury@gmail.com]
>> Inviato: lunedì 31 luglio 2006 21.15
>> A: Derby Discussion
>> Oggetto: Re: R: connection strange behavior
>>
>>
>> Flavio Palumbo wrote:
>>> Hi all,
>>>
>>> sorry for the long delay of this response but I spent a little
>> holiday ;-))
>>> Could you please provide some code examples ?? specially when you say :
>>>
>>> "Usually it is done by defining a global datasource that is started when
>>> the server starts.  Then by setting the property
>>> derby.drda.startNetworkServer to true in the JVM arguments that are set
>>> at Server startup the Network Server will also start.  It is recommended
>>> that he Network Server be started and shutdown when the server starts
>>> and shutdowns and also that a security manager be used to secure the
>>> environment."
>>>
>>> Thanks a lot.
>>>
>>> Flavio
>>>
>>>
>>> Flavio Palumbo wrote:
>>>
>>>> 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
>>>>
>>>>
>>>> === SNIP ========
>>>>
>>> Hi -
>>> Ouch, You are correct when you say:
>>> " (not always the same error, data seems to be lost, strange exceptions
>>> ...) making me think maybe this is not the right way "
>>> Strange exceptions and data loss is what happens when database I/O is
>>> performed across a network.  Your configuration is causing
>> these problems:
>>> " - note that the shared derby DB is in a network shared directory "
>>>
>>> The disks must be local to the machine running the Derby engine.
>>>
>>> A centralized server architecture will handle this.  Start your server
>>> and the Network server on the machine where the database files reside
>>> and have the applications connect either to the server via whatever
>>> protocols it supports or via the Network Server using the client
>>> driver.  How you set this up depend on the server you are using.
>>> Usually it is done by defining a global datasource that is started when
>>> the server starts.  Then by setting the property
>>> derby.drda.startNetworkServer to true in the JVM arguments that are set
>>> at Server startup the Network Server will also start.  It is recommended
>>> that he Network Server be started and shutdown when the server starts
>>> and shutdowns and also that a security manager be used to secure the
>>> environment.
>>>
>>> HTH
>>>
>>>
>>>
>>>
>>> -----------------------------------------------------------
>>> 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.
>>>
>>>
>>>
>> I'm not sure of the architecture you are using.  My response assumed
>> that you were using an Application Server like Geronimo, Tomcat , etc.
>> These each have their own methods for defining Global datasources.  You
>> can find writeups that contain instructions on doing this under 'Product
>> Writeups' on the Apache Derby Resources page:
>> http://db.apache.org/derby/integrate/index.html#products
>>
>> If you are writing your own Server and want to add datasource
>> functionality to it you might want to use the system that Tomcat uses:
>> |commons-dbcp| (http://jakarta.apache.org/commons/dbcp/).
>>
>> Is this what you needed ??
>>
> 
> 
> -----------------------------------------------------------
> 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