• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help - DB Connection from servlet

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a peculiar problem I'm hoping someone can help with. First, let me explain how it works now and then I'll explain what the client wants to do differently.
I have a servlet which in it's init() method opens a single connection to a database. Each service() method uses this connection to run a query. The destroy() method closes the connection when the web server (JWS on Win2000) shuts down.
The client would like to run maintenance on the datbase every night and this requires exclusive use of the database. The only way to release the servlet's connection is to shut down the web server. Obviously, this is not ideal. Also, the client does not want the hassle of running a duplicate database for several reasons, not the least of which is the shear size of the files.
The client has asked for a GUI application that they can click on that closes the connection and causes web site users to see "Database down - please come back in 5 minutes" or a similar message. After maintenance, they can click on a button and resume normal operation.
Can this be done? Can I launch a GUI from a servlet's init() and have that GUI control the connection? If not, any other ideas? (I have a sneaky suspicion I'm missing something VERY obvious)
Your help is greatly appreciated!
Arsin Delve.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You ARE missing something obvious! Add some logic inside the servlet to look for an undocumented URI that does the lock/unlock. Secure this URI by refusing to process it unless objective proof is given that the user is authorized. If the "magic" URI is supplied AND the security is OK'd, invoke the lock/unlock function. Non-magic URI's go through the normal processing, and you can toss back a suitable status code for unauthorized magic URI's.
Why write a GUI when the user's web browser is a GUI?
 
Arsin Delve
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had to read that about 4 times to understand whay you meant, but once I did I thought it was terrific! What a great idea, thanks so much!
I think I understand URI from the context, but what does it mean? Did you rather mean URL?
-Arsin Delve.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic