dbTalk Databases Forums  

looking for examples of multithreaded Java code accessing BerkeleyDb

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss looking for examples of multithreaded Java code accessing BerkeleyDb in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Stan Pinte
 
Posts: n/a

Default looking for examples of multithreaded Java code accessing BerkeleyDb - 09-25-2003 , 03:49 AM






hello,

has anyone working examples of multiple threads sharing the same DbEnv
to write and read to a database (in my case an XmlContainer)?

I am trying to do that from a servlet engine, and have no success
until now: I must close and open my XmlContainer for each transaction,
and it is extremely slow.

thanks a lot,

Stan.

Reply With Quote
  #2  
Old   
Emiliano
 
Posts: n/a

Default Re: looking for examples of multithreaded Java code accessing BerkeleyDb - 09-25-2003 , 04:21 AM






In article <89910ac4.0309250049.143dbd89 (AT) posting (DOT) google.com>, Stan Pinte wrote:
Quote:
hello,

has anyone working examples of multiple threads sharing the same DbEnv
to write and read to a database (in my case an XmlContainer)?

I am trying to do that from a servlet engine, and have no success
until now: I must close and open my XmlContainer for each transaction,
and it is extremely slow.
Can't you just have a DbEnv for each thread? I can see how sharing the
DbEnv across threads won't work, unless you wrap it all in synchronized
sections, but multiple DbEnvs on one database must be possible. If not,
I don't see how BDB/xml can be used in servlets at all.

--
Emiliano


Reply With Quote
  #3  
Old   
Chad
 
Posts: n/a

Default Re: looking for examples of multithreaded Java code accessing BerkeleyDb - 09-25-2003 , 11:59 AM



See docs for DbEnv.open method.
You can pass in DB_THREAD as part of the flags param.





Emiliano <nospam (AT) iris-advies (DOT) nl> wrote

Quote:
In article <89910ac4.0309250049.143dbd89 (AT) posting (DOT) google.com>, Stan Pinte wrote:
hello,

has anyone working examples of multiple threads sharing the same DbEnv
to write and read to a database (in my case an XmlContainer)?

I am trying to do that from a servlet engine, and have no success
until now: I must close and open my XmlContainer for each transaction,
and it is extremely slow.

Can't you just have a DbEnv for each thread? I can see how sharing the
DbEnv across threads won't work, unless you wrap it all in synchronized
sections, but multiple DbEnvs on one database must be possible. If not,
I don't see how BDB/xml can be used in servlets at all.

Reply With Quote
  #4  
Old   
Dan Creswell
 
Posts: n/a

Default Re: looking for examples of multithreaded Java code accessing BerkeleyDb - 10-07-2003 , 03:16 AM



Stan Pinte wrote:
Quote:
hello,

has anyone working examples of multiple threads sharing the same DbEnv
to write and read to a database (in my case an XmlContainer)?

Yes, I've done it - I specify:

Db.DB_PRIVATE

Because I have a single JVM (with multiple threads) accessing the databases.

For Java, Db.DB_THREAD is assumed as a default so you shouldn't need to
specify it explicitly.

In this case, I suspect you are losing (it's being GC'd) the reference
to the DbEnv instance - where do you keep the DbEnv reference?

Quote:
I am trying to do that from a servlet engine, and have no success
until now: I must close and open my XmlContainer for each transaction,
and it is extremely slow.

thanks a lot,

Stan.
Dan.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.