java - values keep looping -
this did. want stockid, stock name , stockprice under each . unfortunately, keeps on looping. means that, suppose have s0001 xxx 19.90 instead having s0001 abc 19.90, s0002 abc 19.90, s0003 abc 19.90, s0004 abc 19.90. go s0001 , abc change next value in database. means stockname loop 4 times while stockprice loop 12 times.
<sql:setdatasource url="jdbc:derby://localhost:1527/healthdb;user=nbuser;password=nbuser" driver="org.apache.derby.jdbc.clientdriver" var="derbydata"/> <sql:query sql=" select stockid stocks" datasource="${derbydata}" var="stocks" /> <sql:query sql=" select stockname stocks" datasource="${derbydata}" var="stocks1" /> <sql:query sql=" select stockprice stocks" datasource="${derbydata}" var="stocks2" /> <table border="1"> <thead> <tr><th> stock id </th> <th> stock name </th> <th> stock price </th> </tr> </thead> <tbody> <c:foreach var="row3" items ="${stocks2.rowsbyindex}"> <c:foreach var="row2" items ="${stocks1.rowsbyindex}"> <c:foreach var="row1" items="${stocks.rowsbyindex}"> <tr> <td> <c:out value="${row1[0]}"/> </td> <td> <c:out value="${row2[0]}"/> </td> <td> <c:out value="${row3[0]}"/> </td> </tr>
simply change query field wanted , use index or 0 1 2 ....
<sql:query sql=" select stockid,stockname,stockprice stocks" datasource="${derbydata}" var="stocks" /> <c:foreach var="row1" items="${stocks.rowsbyindex}"> <tr> <td> <c:out value="${row1[0]}"/> </td> <td> <c:out value="${row1[1]}"/></td> <td> <c:out value="${row1[2]}"/></td> </tr>
Comments
Post a Comment