InsertEmployeeCommand.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package examples.datacommands;
- import java.sql.*;
- import javax.sql.*;
- /**
- * InsertEmployeeCommand, this class
- * is the usecase specific Command bean that
- * an application developer would write.
- */
- public class InsertEmployeeCommand extends BaseUpdateCommand
- {
- static String statement = "insert into Employees (EMPLOYEEID, NAME, EMAIL) values (?,?,?)";
- static final String dataSourceJNDI = "bookPool";
- /**
- * Passes parent class the usecase specific sql statement to use
- */
- protected InsertEmployeeCommand() throws DataCommandException
- {
- super(dataSourceJNDI, statement);
- }
- public void setEmail(String anEmail) throws DataCommandException
- {
- try
- {
- pstmt.setString(3, anEmail);
- } catch (SQLException e)
- {
- throw new DataCommandException(e.getMessage());
- }
- }
- public void setId(int id) throws DataCommandException
- {
- try
- {
- pstmt.setInt(1, id);
- } catch (SQLException e)
- {
- throw new DataCommandException(e.getMessage());
- }
- }
- public void setName(String aName) throws DataCommandException
- {
- try
- {
- pstmt.setString(2, aName);
- } catch (SQLException e)
- {
- throw new DataCommandException(e.getMessage());
- }
- }
- }