File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterate through a ResultSet

 
Ed Chawlik
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fairly new to struts and am trying to interate though an Oracle result set; the SCOTT/TIGER emp table. I saw this on another forum, but cannot get it to work. If someone knows of a better way or how to get this to work, I am all ears:

Regards, ed

Java Action code (works fine)

stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT EMPNO, ENAME FROM scott.emp");
rsdc = new RowSetDynaClass(rset);
request.setAttribute("customers", rsdc);
...

JASP code:

<logic:iterate id="customer" name="customers" property="rows" scope="request">
<br>This is filler text
<bean:write name="customer" property="EMPNO"/>  
<bean:write name="customer" property="ENAME"/>
</logic:iterate >

Error:


javax.servlet.ServletException: No getter method for property EMPNO of bean customer
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.masterlist_jsp._jspService(masterlist_jsp.java:215)
...
 
Ergin Er
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you should convert the ResultSet to a List before you put it into session?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The trouble with this code is that your variable "customer" is of type DynaBean, and DynaBean is not a true javaBean. There is no getEMPNO() method but only a get(String) method. My suggestion would be to create an Employee bean. You could then create a list of Employee beans and use the BeanUtils.copyProperties() method to copy the properties of the DynaBean to the Employee bean.
 
Ed Chawlik
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys, I will give that a try.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic