Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Write a thread to check database in web application

Write a thread to check database in web application

2007-11-05       - By Frank W. Zammetti

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  


On Mon, November 5, 2007 11:17 am, Ashish Kulkarni wrote:
> Hi
> I dont need more then one thread, or a timer job i would say, this timer
> should sleep and then activate like after 10 minutes, check the database,
> if
> there is nothing to do go back to sleep.
> I will look into quartz, is it ok to use Java Timer and TimerTask to do
> it.

Although I can't say I've ever done it that way, I don't see why it would
be any worse than a straight Thread approach... it might even be better
because the JVM might have a little more control over its management and
can possibly cooperate with the container a little better, but I don't
know that for sure (I also wouldn't be one bit surprised if Timers in Java
are just a thin abstraction around a Thread anyway).

> I will make sure that the class with does check database function will not
> go in loop or be there for ever

You'll also *probabyly* want to get your DB connection the same way as any
app code, which I presume is a JNDI lookup.  At least that way you get
some of that benefit in term of management, but there is a prime example
of making sure that thread code doesn't do anything unsavory... it'd be a
real shame to somehow keep that connection from being returned to the pool
and then find the thread continues to fine and eat a connection each time
:) (I've had this debate with some folks and there's also the thought that
NOT using the same conn pool as the container is actually better because
then the pool can't be exhausted... then again, at that point you run the
risk of chewing up the listener threads in the RDBMS, so six of one, half
dozen of another I figure).

Frank

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@(protected)
Author of "Practical Ajax Projects With Java Technology"
(2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
(2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.