Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieving multiple rows from database and display using struts2
    primarykey
    data
    text
    <p>I am developing a photo album web application in which I am using two tables USER_INFORMATION and USER_PHOTO. USER_INFORMATION contains only user record which is one record, USER_PHOTO contains more than one photo form a single user. I want to get the number of user information along with their userimage path and store it in to a Java Pojo variable like a list so that I can display it using display tag in struts 2.</p> <p>The table goes like this.</p> <pre><code> USER_PHOTO USER_INFORMATION ======================= ================================= | IMAGEPATH | USER_ID | | USER_NAME | AGE | ADDRESS |ID | ======================= ================================= |xyz | 1 | | abs | 34 | sdas | 1 | |sdas | 1 | | asddd | 22 | asda | 2 | |qwewq | 2 | | sadl | 121 | asd | 3 | | asaa | 1 | ================================== | 121 | 3 | ======================= </code></pre> <p>i some what manage to get the user information correctly by using HashSet and display tag the code goes like this...</p> <pre><code> public ArrayList loadData() throws ClassNotFoundException, SQLException { ArrayList&lt;UserData&gt; userList = new ArrayList&lt;UserData&gt;(); try { String name; String fatherName; int Id; int age; String address; String query = "SELECT NAME,FATHERNAME,AGE,ADDRESS,ID FROM USER_INFORMATION ,USER_PHOTO WHERE ID=USER_ID"; ps = con.prepareStatement(query); ResultSet rs = ps.executeQuery(); while (rs.next()) { name = rs.getString(1); fatherName = rs.getString(2); age = rs.getInt(3); address = rs.getString(4); //Id = rs.getInt(5); UserData list = new UserData(); list.setName(name); list.setFatherName(fatherName); list.setAge(age); list.setAddress(address); //list.setPhot(Id); userList.add(list); } ps.close(); con.close(); } catch (Exception e) { e.printStackTrace(); } ArrayList al = new ArrayList(); HashSet hs = new HashSet(); hs.addAll(userList); al.clear(); al.addAll(hs); //return (userList); return al; </code></pre> <p>and my display tag goes like this in jsp...</p> <pre><code> &lt;display:table id="data" name="sessionScope.UserForm.userList" requestURI="/userAction.do" pagesize="15" &gt; &lt;display:column property="name" title="NAME" sortable="true" /&gt; &lt;display:column property="fatherName" title="User Name" sortable="true" /&gt; &lt;display:column property="age" title="AGE" sortable="true" /&gt; &lt;display:column property="address" title="ADDRESS" sortable="true" /&gt; &lt;/display:table&gt; </code></pre> <p>as u can see i am displaying only user information not his photo uploaded i want to display his uploaded filename also. i some what created another table to store his photo information. if i include <strong>Imagepath</strong> attribute in my sql query than their will be duplicate rows means if user have uploaded 5 photos than display tag will display five records with same information with different ImagePath.<br> so any can tell me hoe make it to display only one record of user information with his multiple ImagePath so that it not display user information repeatedly. </p> <p><strong>Thanks In Advance</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload