aspose file tools
The moose likes JDBC and the fly likes JDBC Connection Utility:  static class? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "JDBC Connection Utility:  static class?" Watch "JDBC Connection Utility:  static class?" New topic
Author

JDBC Connection Utility: static class?

Irachi Chishima
Greenhorn

Joined: Nov 26, 2001
Posts: 5
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

Joined: Apr 22, 2001
Posts: 63
That should be just fine. I company where I worked some guys did just that like you and it was OK!


Vladimir Ergovic
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JDBC Connection Utility: static class?
 
Similar Threads
When do I need to be concerned with threading?
Connecting to multiple databases using different jdbc drivers
NX: URLYBird / my approach of the reading problem
open database connection
FBNS: Inherit from Data class and How to operate db.db