📄 queryemployeebynamecommand.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -