In my project i am having DBUtils package. This package consists of classes with all static methods that interact with database. My project is web based.will i get concurrency problems when accessing static methods of my DBUtils package.
Can any one tell me where can i get concurrency problem...
Sorry ,yesterday i posted wrongly..DBUtils is a class not a package.
I am posting a sample code ..static method that interacts with database
This is the sample code.I am having DAO layer.In DAO I won't write the JDBC code.I am writing in DBUtils class.
In DAO's iam calling the static methods of DBUtils class
So when 2 users send request then 2 threads will create.while accessing this static method any concurrent issues arise or not.
If arise ,what is the solution.
Please anyone tell the solution..
I don't think you need to synchronize all the static methods. Especially if your static methods do not modify any shared resources. Databases have their own implementation of concurrency control. You need to visit each and every method and evaluate whether or not you need to synchronize. These decisions has to be taken on a case by case basis.
In my project iam almost everywhere using DBUtils class which consists of database access static methods.Suppose ,If i go on creating the objects for DBUtils class then a lot of objects will be created.Instead of creating objects i made my methods static. I thought that adds support to performance....
Jeanne Boyarsky
,
author & internet detective
staff
ConnectionManager is a singleton class.ConnectionManager.getInstance() returns the instance and ConnectionManager.getInstance.getConnection method returns connection object.
In the getConnection method i wrote the database connection code.
I used the DBUtils class almost everywhere in the project. Now if make every method in DBUtils as instance method, my team had to work a lot.In the whole project they need to modify..So ,tell me that i can modify in only DBUtils class.
Thanking & Regards,
Vipul Reddy Bondugula.
Jeanne Boyarsky
,
author & internet detective
staff
vipul bondugula wrote: ConnectionManager is a singleton class.ConnectionManager.getInstance() returns the instance and ConnectionManager.getInstance.getConnection method returns connection object.
In the getConnection method i wrote the database connection code.