com.partnersoft.sql
Class SqlConnectionKeepAlive

java.lang.Object
  extended by java.lang.Thread
      extended by com.partnersoft.gadgets.LoopingThread
          extended by com.partnersoft.sql.SqlConnectionKeepAlive
All Implemented Interfaces:
java.lang.Runnable

public class SqlConnectionKeepAlive
extends LoopingThread

A looping thread that keeps an SQL connection alive by doing a small operation every so often.

Needing this is probably an indication of a bad design, but if you don't have time to fix the design, this might be very useful.

Copyright 2010 Partner Software, Inc.

Version:
$Id: SqlConnection.java 2289 2009-12-04 17:05:10Z paul $
Author:
Paul Reavis

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SqlConnectionKeepAlive(java.sql.Connection connection)
          Starts an keep-alive thread with a 1-hour loop interval.
SqlConnectionKeepAlive(java.sql.Connection connection, Duration interval)
           
SqlConnectionKeepAlive(SqlConnection connection)
          Starts an keep-alive thread with a 1-hour loop interval.
SqlConnectionKeepAlive(SqlConnection connection, Duration interval)
           
 
Method Summary
 void runTask()
          By default, this runs the runnable.
 
Methods inherited from class com.partnersoft.gadgets.LoopingThread
getInterval, getTask, isRunning, pauseLooping, resumeLooping, run, setInterval, setTask, start, stopRunning
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SqlConnectionKeepAlive

public SqlConnectionKeepAlive(SqlConnection connection,
                              Duration interval)

SqlConnectionKeepAlive

public SqlConnectionKeepAlive(java.sql.Connection connection,
                              Duration interval)

SqlConnectionKeepAlive

public SqlConnectionKeepAlive(SqlConnection connection)
Starts an keep-alive thread with a 1-hour loop interval.


SqlConnectionKeepAlive

public SqlConnectionKeepAlive(java.sql.Connection connection)
Starts an keep-alive thread with a 1-hour loop interval.

Method Detail

runTask

public void runTask()
             throws java.lang.Exception
Description copied from class: LoopingThread
By default, this runs the runnable. Subclasses may also override it directly (e.g. in anonymous or inner classes). Exceptions will be caught and reported but will stop the thread.

Overrides:
runTask in class LoopingThread
Throws:
java.lang.Exception