db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Leroux <s...@wanadoo.fr>
Subject Re: I need some help
Date Mon, 31 Aug 2009 08:23:36 GMT
chengzhuo a écrit :
> 
>   hello derby!  
> Refers to Derby being started by a simple single-user Java application. With this 
> 
> option Derby runs in the same Java virtual machine (JVM) as the application. 
> 
>  
>  
> Is it means that only one user can access the database at the same time ?
>      thank you.
>  
> 2009-08-31
> chengzhuo

Hi,

That's what a lot of beginners thinks at first. The main reason, I 
think, is that "access the database" may have two different meanings 
when talking about Derby: *boot* the DB, or *connect* to the DB.


 From one JVM, Derby allow you to open several concurrents *connexions* 
- each of them for a different user and/or database if you want.

You have the proof with ij when opening several connexions to the same DB:
ij> connect 'jdbc:derby:sample' user 'sylvain' password 'pass';
ij> connect 'jdbc:derby:sample' user 'sonia' password 'pass';
ij(CONNECTION1)=> show connections;
CONNECTION0  -   jdbc:derby:sample
CONNECTION1* -   jdbc:derby:sample

But this will /not/ work in two different instances of ij (i.e. running 
in different JVM). Because each of them will try to *boot* the same DB.


The key points to remember are:
* only one JVM can boot ("open") a derby database
* /but/ that JVM can open several connections to that database.

Please, see the following link for more informations:
http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html#just_one_app


Of course, this has an impact on your application design. Since it must 
be able to manage several concurrent connections. If you are developing 
a rich client, perhaps the server version of Derby might have been a 
better choice.


Best regards,
Sylvain,

-- 
Website: http://www.chicoree.fr



Mime
View raw message