CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > Web服务子站 > Java技术

关于EJB返回值的最好的解决方案

作者: 佚名,  出处:IT专家网论坛, 责任编辑: 包春林, 
2008-05-13 04:00
  相信很多人都有如此之困惑,得此解决方法不敢独享,公之于众,以利后来人。

  有两种方法:

  1、用vector:

  

      /**

  * Finds all EJBeans with a balance greater than a given amount.

  * Returns an Enumeration of found EJBean primary keys.

  *

  * @param balanceGreaterThan double Test Amount

  * @return Enumeration EJBean Primary Keys

  * @exception javax.ejb.EJBException

  * if there is a communications or systems failure

  */

  public Enumeration ejbFindBigAccounts(double balanceGreaterThan) {

  log("ejbFindBigAccounts (balance > " + balanceGreaterThan + ")");

  Connection con = null;

  PreparedStatement ps = null;

  try {

  con = getConnection();

  ps = con.prepareStatement("select id from ejbAccounts where bal ?");

  ps.setDouble(1, balanceGreaterThan);

  ps.executeQuery();

  ResultSet rs = ps.getResultSet();

  Vector v = new Vector();

  String pk;

  while (rs.next()) {

  pk = rs.getString(1);

  v.addElement(pk);

  return v.elements();

  } catch (SQLException sqe) {

  log("SQLException: " + sqe);

  throw new EJBException (sqe);

  } finally {

  cleanup(con, ps);

  }

  }

共2页。 1 2 :

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

       
天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2008, Ctocio.com.cn
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i