org.jcrontab.data
Class GenericSQLSource

java.lang.Object
  |
  +--org.jcrontab.data.GenericSQLSource
All Implemented Interfaces:
DataSource

public class GenericSQLSource
extends java.lang.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.27 $
Author:
$Author: iolalla $

Field Summary
static java.lang.String queryAll
          This Query gets all the Crontab entries from the events table
static java.lang.String queryRemoving
          This Query removes the given Crontab Entries
static java.lang.String querySearching
          This Query gets all the Crontab entries from the events table but searching by the name
static java.lang.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  java.sql.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  java.lang.Object loadDatabaseDriver(java.lang.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 java.lang.String queryAll
This Query gets all the Crontab entries from the events table


querySearching

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


queryStoring

public static java.lang.String queryStoring
This Query stores the Crontab entries


queryRemoving

public static java.lang.String queryRemoving
This Query removes the given Crontab Entries

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,
                             java.lang.ClassNotFoundException,
                             java.sql.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
java.lang.ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
java.sql.SQLException - Yep can throw an SQLException too
DataNotFoundException

findAll

public CrontabEntryBean[] findAll()
                           throws CrontabEntryException,
                                  java.lang.ClassNotFoundException,
                                  java.sql.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
java.lang.ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
java.sql.SQLException - Yep can throw an SQLException too
DataNotFoundException

remove

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

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

store

public void store(CrontabEntryBean[] beans)
           throws CrontabEntryException,
                  java.lang.ClassNotFoundException,
                  java.sql.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
java.lang.ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
java.sql.SQLException - Yep can throw an SQLException too

store

public void store(CrontabEntryBean bean)
           throws CrontabEntryException,
                  java.lang.ClassNotFoundException,
                  java.sql.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
java.lang.ClassNotFoundException - cause loading the driver can throw an ClassNotFoundException
java.sql.SQLException - Yep can throw an SQLException too

getConnection

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

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

loadDatabaseDriver

protected java.lang.Object loadDatabaseDriver(java.lang.String srcName)
                                       throws java.sql.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.
java.sql.SQLException