• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web apps design question

 
carl chan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all:
I am building a web app now and everything works fine. However, instead of asking my DAO(Data access object) to connect to the DB(mysql) to retreive data for my servlet and jsp and stuff, I want to create a virtual database which holds the data.
I know that the database will be reset everytime a new user log-in but thats fine. All I need is that the database will reflect the changes within the session.
My question is that how should I designed my DB class so that it satisfy what I needed.
The current problem i have is that each time my DAO have to create an instance of my DB class (which reset all the changes that user made).
To make my question simpler for those who don't want to READ:
How can I create a class which other objects within the same package can just reference to it and the class itself have 1 instance only??
thx
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this object specific to each user, or just the application?
If it's specific to each user, then just check for its existence in the session, if not, then create it and stick it in.
If it's specific to the application, then you can do the same thing, except put it in the servletContext.
Oh, and you'll definately want to make sure it's thread safe.
[ October 30, 2003: Message edited by: Phil Chuang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic