Title: ExpenseManager Application
Hi Ravi, i think you can mantain this using a SystemManager and DatabaseManager class that uses a Singleton design pattern, for example.
 
public class SystemManager {
    private static SystemManager instance;
    private DatabaseManager db;
 
    private SystemManager() {  // constructor
        db = new DatabaseManager();
    }
 
    public static SystemManager getInstance() {
        if ( instance == null ) instance = new SystemManager();
        return instance;
    } 
 
    public DatabaseManager getDBManager() {
        return db;
    } 
 
}
 
public class DatabaseManager {
    private con1 = ...;
 
    public DatabaseManager() {
        con1 = new Connection(...);
    }
 
    public java.sql.Connection getConnection() {
        return con1;
    }
 
}
 
any time in your development, you can call getInstance() method of the SystemManager class. It will return the unique instance of this class wich has the desired DatabaseConnection instance.
 
hope i could help you.
 
Regards,
 
Marcelo d'Amorim.
 
 
----- Original Message -----
Sent: Tuesday, February 08, 2000 4:58 AM
Subject: ExpenseManager Application

Hi all,

I am trying to create an application which enables people to keep track of their expenses. Here I am validating a user against a member list in an Access database via a "LoginManager" servlet and which then displays his account summary. So far so good. What I am doing is creating a connection to the database in the servlets init method so that the connection persists till the end of the session.

Now after throwing the accounts summary page I give the user the option of adding a new expense. Which is nothing but a link to another servlet, say "AccountsManager". Now do I have to open the connection to the database once again, since this is another servlet that I am invoking.

Can I have one servlet which establishes a connection at the very beginning of the login and then every other query into the database makes use of this connection. If yes, how do I do this? I am presently using Jason Hunter's book as my reference.

Thanks k Regards

Ravi Kumar Gopalankutty
Cognizant Technology Solutions,
Ph: 044-2354281 Extn:4423
e-mail: [EMAIL PROTECTED]
_______________________________________________________________


Reply via email to