All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.dao.executable.InsertExecutable Maven / Gradle / Ivy

package nyla.solutions.dao.executable;

import nyla.solutions.dao.AbstractDaoOperation;
import nyla.solutions.dao.SQL;
import nyla.solutions.global.exception.ConfigException;
import nyla.solutions.global.exception.SystemException;
import java.sql.*;
import nyla.solutions.global.patterns.command.Environment;

/**
 * @author Gregory Green
 * @version 1.0
 *  * @deprecated use commands
 *
 * InsertExecutable  represents an executed insert statement
 * 
 * 
 */
@Deprecated
public class  InsertExecutable extends AbstractDaoOperation
//implements Executable, Command
{
	/**
	 * Execute an insert statement
	 */
	public void execute(Environment env, String[] args)
	{		
		 if(this.getSql() == null || this.getSql().length() == 0)
	         throw new ConfigException("Property \"sqlQuery\"  not setin "+this.getClass().getName());
	      
	      SQL sql = null;
	      try
	      {
	         sql = this.connect();   
	         
	         sql.insert(getSql());
	         
	         sql.commit();
	      }
	      catch(SQLException e)
	      {
	         sql.rollback();
	         
	         throw new SystemException(e);
	      }
	      finally
	      {
	         if(sql != null)
	            sql.dispose();
	      }      
	}//---------------------------------------------
	
	/**
	 * Wrapper execution for a command
	 * @source
	 * @see solutions.global.patterns.command.Command#execute(java.lang.Object)
	 */
	public Object execute(Environment source)
	{
		execute(null,null);
		
		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy