db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Bradbury <Stan.Bradb...@gmail.com>
Subject Re: R: connection strange behavior
Date Mon, 31 Jul 2006 19:14:56 GMT
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 ??


Mime
View raw message