结合ValueOject 模式,代理模式,门面模式,建议你看看j2ee 设计模式
解决方案 »
- Java开发的B2C网站的商品站内搜索用什么技术比较好?
- 麻烦前辈们帮我看看这段代码哪里有误呢?
- spring 简单问题
- hibernate 新手, 愁死啦。 俺再搞不出来 ,就要回家 卖地瓜啦1
- 请问各位大侠,用java怎么调用delphi写的dll里面的函数.最好能给个例子,谢谢了!!
- 请问要架设类似新浪,网易,搜狐这中公共的邮件服务器需要有什么条件?
- 如何安装mysql的驱动程序为tomcat连接数据库用?!
- ********struts小问题 50分!!来者有分! *********
- 高难度struts-图片插入数据库
- EJB中的NextID的问题
- 求救编译时出现的错误!
- 新手探路:我现在该看EJB还是设计模式,还是进一步加深基础???
EntityContext entityContext;
long flightID;
FlightSCHDData flightSCHDData;
public void ejbLoad() {
FlightSCHDPK pk = (FlightSCHDPK)entityContext.getPrimaryKey();
setFlightID(pk.flightID);
try {
flightSCHDData = selectByPrimaryKey(new FlightSCHDPK(getFlightID()));
setFlightSCHDData(flightSCHDData);
}
catch (SQLException se) {
logger.error(se.getErrorCode()+se.getMessage());
}
} public void setFlightSCHDData(FlightSCHDData flightSCHDData) {
this.flightSCHDData = flightSCHDData;
}
public FlightSCHDData getFlightSCHDData() {
return flightSCHDData;
} /////////////////////////////////////// SQL methods
private FlightSCHDData selectByPrimaryKey(FlightSCHDPK pk) throws SQLException {
Connection con = null;
PreparedStatement prepStmt =null;
FlightSCHDData plandata=null;
try{
String selectStatement = "select* from table "
con = DBConnectionFactory.getConnection();
prepStmt = con.prepareStatement(selectStatement);
prepStmt.setLong(1, pk.flightID);
ResultSet rs = prepStmt.executeQuery(); if (rs != null && rs.next()) {
plandata = createFlightSCHDData(rs);
}
if(rs!=null)
rs.close();
}
catch(SQLException se){
DBConnectionFactory.closeStatement(prepStmt);
DBConnectionFactory.releaseConnection(con);
throw se;
}
finally{
DBConnectionFactory.closeStatement(prepStmt);
DBConnectionFactory.releaseConnection(con);
}
return plandata;
} public java.util.Collection ejbFindByQueryStr(String query) throws FinderException { String selectStatement = "select FLIGHT_ID from " + TableName.FLTOPRSCHD +" Q "+ query;
Connection con = null;
Statement stmt = null;
ArrayList a = new ArrayList();
try {
con = DBConnectionFactory.getConnection();
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(selectStatement); while (rs != null && rs.next()) {
FlightSCHDPK pk = new FlightSCHDPK(rs.getLong(1));
a.add(pk);
}
if(rs !=null) rs.close();
logger.debug("found " + a.size() + " QueryStr: " + query);
}
catch (SQLException se) {
DBConnectionFactory.closeStatement(stmt);
DBConnectionFactory.releaseConnection(con);
throw new FinderException(ErrorCodeConvert.getErrorCode(Integer.toString(se.getErrorCode())));
}
finally{
DBConnectionFactory.closeStatement(stmt);
DBConnectionFactory.releaseConnection(con);
}
return a;
}
}