/* ===================================================================
* SqlStatementJob.java
*
* Created Oct 26, 2009 2:25:30 PM
*
* Copyright (c) 2009 Solarnetwork.net Dev Team.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
* ===================================================================
* $Id: SqlStatementJob.java 398 2009-10-26 01:39:27Z msqr $
* ===================================================================
*/
package net.solarnetwork.node.dao.jdbc;
import net.solarnetwork.node.job.AbstractJob;
import org.quartz.JobExecutionContext;
import org.springframework.jdbc.core.JdbcTemplate;
/**
* Job to execute a SQL update statement of some kind.
*
* <p>This can be used to execute periodic SQL administration tasks, such as the
* "SHUTDOWN COMPACT" command in hsqldb.</p>
*
* @author matt
* @version $Revision: 398 $ $Date: 2009-10-26 14:39:27 +1300 (Mon, 26 Oct 2009) $
*/
public class SqlStatementJob extends AbstractJob {
private JdbcTemplate jdbcTemplate;
private String sql;
@Override
protected void executeInternal(JobExecutionContext jobContext)
throws Exception {
if ( log.isDebugEnabled() ) {
log.debug("Executing SQL: " +sql);
}
jdbcTemplate.execute(sql);
if ( log.isInfoEnabled() ) {
log.info("Executed SQL: " +sql);
}
}
/**
* @return the jdbcTemplate
*/
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
/**
* @param jdbcTemplate the jdbcTemplate to set
*/
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
/**
* @return the sql
*/
public String getSql() {
return sql;
}
/**
* @param sql the sql to set
*/
public void setSql(String sql) {
this.sql = sql;
}
}