queryemployeebynamecommand.java

来自「100多M的J2EE培训内容」· Java 代码 · 共 66 行

JAVA
66
字号
package examples.datacommands;


import java.sql.*;
import javax.sql.*;

/**
 * A usecase specific querying object
 **/
public class QueryEmployeeByNameCommand extends BaseReadCommand
{

    static final String statement = "select EMPLOYEEID, NAME, EMAIL from Employees where NAME = ?";
    static final String dataSourceJNDI = "bookPool";

    protected QueryEmployeeByNameCommand() throws DataCommandException
    {
        super(dataSourceJNDI, statement);
    }

    public String getEmail() throws DataCommandException
    {
        try
        {
            return rowSet.getString(3);
        } catch (SQLException e)
        {
            throw new DataCommandException(e.getMessage());
        }
    }

    public int getId() throws DataCommandException
    {
        try
        {
            return rowSet.getInt(1);
        } catch (SQLException e)
        {
            throw new DataCommandException(e.getMessage());
        }
    }

    public String getName() throws DataCommandException
    {
        try
        {
            return rowSet.getString(2);
        } catch (SQLException e)
        {
            throw new DataCommandException(e.getMessage());
        }
    }

    public void setName(String aName) throws DataCommandException
    {
        try
        {
            pstmt.setString(1, aName);
        } catch (SQLException e)
        {
            throw new DataCommandException(e.getMessage());
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?