Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2005

Tip: Looking for answers? Try searching our database.

Transaction manager (Objectstore)

Thread view: 
sid derra - 07 Jun 2005 13:16 GMT
Hi

I currnently am working on a project which is supposed to run with an
Objectstore (actually PSE-Pro) DB-backend.
Now i have a little question to the group: Would any of you like to share a
design pattern or code snippet for a transaction manager class? It should
take care of the access to the Objectstore-ressources (locks, threads,...)
to prevent exceptions and allow serializability. Google couldnt really give
me all too many useful results, which is why i'd like to ask you guys.

Thanks a bunch in advance
sid

x-posted
Robert Klemme - 07 Jun 2005 15:49 GMT
> Hi
>
[quoted text clipped - 9 lines]
> Thanks a bunch in advance
> sid

ObjectStore is a page server.  AFAIK they do locking on page level.  You
would have to instrument / consider that.  Depending on how much
concurrency you want smart placing of instances on pages / segments might
be enough.

Kind regards

   robert
Wibble - 08 Jun 2005 04:00 GMT
>>Hi
>>
[quoted text clipped - 18 lines]
>
>     robert

I dont know anything about objectStore but I have built transaction
managers.

class ConnectionManager {
  public static ConnectionManager getSingleton();
  public Connection getNamedConnection(String name);
  public void beginTransaction();
  public void endTransaction(boolean commitp);
}
ConnectionManager.getSingleton().beginTransaction();
boolean commitp = false;
try {
  Connection conn =
    ConnectionManager.getSingleton().getNamedConnection("odi:pool");
  /* do stuff */
  commitp = true;
}
finally {
  // commitp is false on exception, so votes to rollback.
  ConnectionManager.getSingleton().endTransaction(commitp);
}

Store the transaction object in a thread local.  beginTransaction
increments a count so the begin/ends can nest.  endTransaction
decrements the counter.  When it goes to zero, if any endTransaction
or any Connection voted against commit, then rollback.

getNamedConnection ensures that a connection from the named pool
lives in the transaction.  All connections in the transaction
are committed together or rolled back together in a two-phase
commit.  Theres some risk that the commits fail, but its about
as good as you can do without a real XA transaction.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.