• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC Connection Utility: static class?

 
Irachi Chishima
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a JDBC connection utility to connect Lotus Notes to an Oracle database. It can be called from different part of Notes (like different client classes) but I need to make sure that only one thread can have the database connection at a time (long story!). I am thinking about writing my connection utility class as with static synchronized methods. That way no two instances of the class could be calling the method at the same time (because of the lock set by "synchronized"). I am actually not planning to actually instantiated the class anyway since the only method I need is static. Will this guarantee that any client that uses my connection utility class will have exclusive control of the connection?
I am a newbie at this and am wondering if I am going about designing this the correct way. Any suggestions would be much appreciated. Thanks.
 
Vladimir Ergovic
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That should be just fine. I company where I worked some guys did just that like you and it was OK!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!