ex8_12.txt
来自「j2ee core design patterns」· 文本 代码 · 共 57 行
TXT
57 行
Example 8.12 TORowMapper.java: A Sample Implementation
package com.corej2eepatterns.util;
// imports
public class TORowMapper {
// create Customer TO
public CustomerTO createCustomerTO(RowSet rowSet) {
CustomerTO to = new CustomerTO();
to.setId(getString(rowSet), 0);
to.setName(getString(rowSet), 1);
. . .
}
// create other TOs
. . .
// implement primitive methods used by create methods
protected boolean wasNull(RowSet rowSet) {
try {
return rowSet.wasNull();
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
}
}
protected String getString(RowSet rowSet, int columnIndex) {
try {
return rowSet.getString(columnIndex);
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
}
}
protected boolean getBoolean(
RowSet rowSet, int columnIndex) {
try {
return rowSet.getBoolean(columnIndex);
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
}
}
protected java.util.Date getDate(
RowSet rowSet, int columnIndex) {
try {
return rowSet.getDate(columnIndex);
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
}
}
// Other primitive getXXX methods for all required
// data types
. . .
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?