Database access, JDBC/ODBC, could even brush on some SQL
JDBC Connection Utility: static class?
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.
That should be just fine. I company where I worked some guys did just that like you and it was OK!