Making Data class Singleton.. Providing the database consistency problem?
posted 11 years ago
I have a question about the Data Singleton class. If I have to use the same Data class, which is in "suncertify.db" package, both in standalone mode and networked mode. Suppose that I run a server and I have a network client requesting a servie,the server knows which server database file(from suncertify.properties file) should be properly used for this networked mode and the Data Singleton class will be mapped to this server database file. While this should be no problem, if, at the same time, i run this application on this server machine that is servicing that network client, my Data Singleton class now will be mapped to my local database file(in my server machine) then this Data Singleton Class has no longer way to get back to the server database file to service that network client because the Data Singleton class is already mapped to different database file and there is only one instance of the Data class. How could you guys solve this problem? Should I not make the Data class Singleton but I will be raising the thread safe issue then???
Regards, Ken Kirin SCJP SWCD SCJD(B&S In progress)