Query about simulating global variables in java -
I have a question and I think it's trivial for the nearest. However, here - I have an app that connects to the database to read specific information. Now it is being read in many applications on many applications based on the request. So I wanted to restrict the number of connections in the database to , so this is what I did. Considering that I have a database access class, DBAFus 2 strings, A and amp; B I wrote a class global which is as follows - So now I can go ahead and access an Android. Global as B A and Global. In other sections of the B app. But it seems to me wrong because to populate another population; B. I will need to instantify an object from Global and then I will fall back to accessing an Android app. B as Global.A and similarly for B, I could have all the stuff that could be placed inside a Global Constructor in a static block, but still will not help because I still have to go to 'input' for the dbap Global Must have to migrate any object. Any help or indicators in the right direction will be very helpful. You can instantze the static variable, instead of the constraint of the global method, but it is a good style Not:
public class global {constant string A; Static String B; Public Global (DBAccessInput Input) throws exception {super (); DBAccess dbtool = new DBAccess (input); A = dbtool.getA (); B = dbtool.getB (); }}
Static initial (DBAccessInput input) {a = ... b = ...}
Comments
Post a Comment