Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14490145
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68081
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 21:38:49

下载本文示例代码
  相信很多人都有如此之困惑,得此解决方法不敢独享,公之于众,以利后来人。   声明:此方法的至于彭璐大侠,彭大侠可能不常上网,这麽好的方法也不告诉我等之小虾米,只好代劳了。   好了,不废话了,有两种方法:   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、RowSet RowSet tutorial chapter : http://developer.java.sun.com/developer/Books/JDBCTutorial/chapter5.html   rowset是个interface,需要有东西去实现它,sun的规范中给了三个class:cachedrowset,jdbcrowset,webrowset,如果去查jdk1.4 doc和j2skee1.2,有rowset,却没有那三个class,一般的开发工具(至少我的wsad)中也是这样,所以需要下jdbc2.0 opt-pack: http://developer.java.sun.com/developer/earlyAccess/crs/   下下来了再怎么办呢?   装呗!   怎么装呢?   setup呀!   没有呀?   啊,没setup呀,sun干什么吃的,连setup都不做个,也太懒了吧。   哎,我们确实是都被ms惯坏了,看到只有jar,没setup就没辙了,大家好好想想,java最大的特性是什么,就是它的类库可以自由扩充呀,现在明白该怎么做了吧:   1、解包,得到rowset.jar,放在哪随您的意,别丢了就行。   2、在您的开发工具中增加一个路径,如:ROWSET_PATH对应:d:\jdk1.4\jre\rowset.jar(和1的路径对应就行)。   3、右键您的工程文件,出现:property(大多数工具应该都有吧),加上rowset_path。   4、在您的源文件中:import sun.jdbc.rowset.*;   OK,搞定!下面就看您的了。(当然也可以把rowset压到jre里去) 共2页。 1 2 :   相信很多人都有如此之困惑,得此解决方法不敢独享,公之于众,以利后来人。   声明:此方法的至于彭璐大侠,彭大侠可能不常上网,这麽好的方法也不告诉我等之小虾米,只好代劳了。   好了,不废话了,有两种方法:   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、RowSet RowSet tutorial chapter : http://developer.java.sun.com/developer/Books/JDBCTutorial/chapter5.html   rowset是个interface,需要有东西去实现它,sun的规范中给了三个class:cachedrowset,jdbcrowset,webrowset,如果去查jdk1.4 doc和j2skee1.2,有rowset,却没有那三个class,一般的开发工具(至少我的wsad)中也是这样,所以需要下jdbc2.0 opt-pack: http://developer.java.sun.com/developer/earlyAccess/crs/   下下来了再怎么办呢?   装呗!   怎么装呢?   setup呀!   没有呀?   啊,没setup呀,sun干什么吃的,连setup都不做个,也太懒了吧。   哎,我们确实是都被ms惯坏了,看到只有jar,没setup就没辙了,大家好好想想,java最大的特性是什么,就是它的类库可以自由扩充呀,现在明白该怎么做了吧:   1、解包,得到rowset.jar,放在哪随您的意,别丢了就行。   2、在您的开发工具中增加一个路径,如:ROWSET_PATH对应:d:\jdk1.4\jre\rowset.jar(和1的路径对应就行)。   3、右键您的工程文件,出现:property(大多数工具应该都有吧),加上rowset_path。   4、在您的源文件中:import sun.jdbc.rowset.*;   OK,搞定!下面就看您的了。(当然也可以把rowset压到jre里去) 共2页。 1 2 : 下载本文示例代码


关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案关于EJB返回值的解决方案
阅读(110) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~