org.jcrontab.data
Class GenericSQLSource

java.lang.Object
  extended byorg.jcrontab.data.GenericSQLSource
All Implemented Interfaces:
DataSource

public class GenericSQLSource
extends Object
implements DataSource

This class is only a generic example and doesn't aim to solve all the needs for the differents system's. if you want to make this class to fit your needs feel free to do it and remember the license. On of the things this class does is to open a connection to the database , this is nasty and very expensive, y you want to integrate jcrontab with a pool like poolman or jboss it's quite easy, should substitute connection logic with particular one.

Version:
$Revision: 1.37 $
Author:
$Author: iolalla $

Field Summary
static String nextSequence
          This Query finds the next value in the sequence
static String queryAll
          This Query gets all the Crontab entries from the events table
static String queryRemoving
          This Query removes the given Crontab Entries
static String querySearching
          This Query gets all the Crontab entries from the events table but searching by the name
static String queryStoring
          This Query stores the Crontab entries
 
Constructor Summary
protected GenericSQLSource()
          Creates new GenericSQLSource
 
Method Summary
 CrontabEntryBean find(CrontabEntryBean ceb)
          This method searches the Crontab Entry that the class has the given name
 CrontabEntryBean[] findAll()
          This method searches all the CrontabEntries from the DataSource
protected  Connection getConnection()
          Retrieves a connection to the database.
 DataSource getInstance()
          This method grants this class to be a singleton and grants data access integrity
protected  Object loadDatabaseDriver(String srcName)
          Initializes the database engine/data source.
 void remove(CrontabEntryBean[] beans)
          This method removes the given Crontab Entries
 void store(CrontabEntryBean bean)
          This method saves the CrontabEntryBean the actual problem with this method is that doesn't store comments and blank lines from the original file any ideas?
 void store(CrontabEntryBean[] beans)
          This method saves the CrontabEntryBean the actual problem with this method is that doesn't store comments and blank lines from the original file any ideas?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryAll

public static String queryAll
This Query gets all the Crontab entries from the events table


querySearching

public static String querySearching
This Query gets all the Crontab entries from the events table but searching by the name


queryStoring

public static String queryStoring
This Query stores the Crontab entries


queryRemoving

public static String queryRemoving
This Query removes the given Crontab Entries


nextSequence

public static String nextSequence
This Query finds the next value in the sequence

Constructor Detail

GenericSQLSource

protected GenericSQLSource()
Creates new GenericSQLSource

Method Detail

getInstance

public DataSource getInstance()
This method grants this class to be a singleton and grants data access integrity

Specified by:
getInstance in interface DataSource
Returns:
returns the instance

find

public CrontabEntryBean find(CrontabEntryBean ceb)
                      throws CrontabEntryException,
                             ClassNotFoundException,
                             SQLException,
                             DataNotFoundException
This method searches the Crontab Entry that the class has the given name

Specified by:
find in interface DataSource
Returns:
CrontabEntryBean
Throws:
CrontabEntryException - when it can't parse the line correctly
ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
SQLException - Yep can throw an SQLException too
DataNotFoundException

findAll

public CrontabEntryBean[] findAll()
                           throws CrontabEntryException,
                                  ClassNotFoundException,
                                  SQLException,
                                  DataNotFoundException
This method searches all the CrontabEntries from the DataSource

Specified by:
findAll in interface DataSource
Returns:
CrontabEntryBean[] the array of CrontabEntryBeans.
Throws:
CrontabEntryException - when it can't parse the line correctly
ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
SQLException - Yep can throw an SQLException too
DataNotFoundException

remove

public void remove(CrontabEntryBean[] beans)
            throws CrontabEntryException,
                   ClassNotFoundException,
                   SQLException
This method removes the given Crontab Entries

Specified by:
remove in interface DataSource
Throws:
CrontabEntryException - when it can't parse the line correctly
ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
SQLException - Yep can throw an SQLException too

store

public void store(CrontabEntryBean[] beans)
           throws CrontabEntryException,
                  ClassNotFoundException,
                  SQLException
This method saves the CrontabEntryBean the actual problem with this method is that doesn't store comments and blank lines from the original file any ideas?

Specified by:
store in interface DataSource
Throws:
CrontabEntryException - when it can't parse the line correctly
ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
SQLException - Yep can throw an SQLException too

store

public void store(CrontabEntryBean bean)
           throws CrontabEntryException,
                  ClassNotFoundException,
                  SQLException
This method saves the CrontabEntryBean the actual problem with this method is that doesn't store comments and blank lines from the original file any ideas?

Specified by:
store in interface DataSource
Throws:
CrontabEntryException - when it can't parse the line correctly
ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
SQLException - Yep can throw an SQLException too

getConnection

protected Connection getConnection()
                            throws SQLException
Retrieves a connection to the database. May use a Connection Pool DataSource or JDBC driver depending on the properties.

Returns:
a Connection
Throws:
SQLException - if there is an error retrieving the Connection.

loadDatabaseDriver

protected Object loadDatabaseDriver(String srcName)
                             throws SQLException
Initializes the database engine/data source. It first tries to load the given DataSource name. If that fails it will load the database driver. If the driver cannot be loaded it will check the DriverManager to see if there is a driver loaded that can server the URL.

Parameters:
srcName - is the JDBC DataSource name or null to load the driver.
Throws:
SQLExcption - if there is no valid driver.
SQLException