DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2005
    Location
    ROC
    Posts
    6

    Why getProperty values a different data records

    The purpose , in index.jsp call javabeans, my database has four reocords in all, but javabeans runs out of index.jsp to be only one record. and delete serial number address is 4 , it is wrong! Is it del.jsp?PersonID =1 is correct, because this is serial number is 1, who can tell me the fault that where my logic,and it is four records that right , but the page has one records , thanks.

    Index.jsp
    Code:
    <jsp:useBean id="delete" scope="session" class="com.DeleteBean">
    </jsp:useBean>
    <jsp:setProperty name="delete" property="driverClass" value="SELECT * FROM PERSON_INFO"/>
    <head>
    <title></title>
    <script type="text/javascript" src="function.js"></script>
    </head>
    <%
    	Database qu1 = new Database();
    	qu1.queryConnection();
    
    
    	int per_id;
    	String per_name;
    	String per_birth;
    	String per_tel;
    	String per_salary;
    %>
    <body>
    <center><jsp:useBean id="banner" scope="session" class="com.BannerBean">
    </jsp:useBean>
    <img src="<jsp:getProperty name="banner" property="bannerURL"/>"/></center>
    <table border="1" width="100%">
      <tr>
        <td width="20%" align="center"><font size="2" face="Arial">Num</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Name</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Birth</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Tel</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Salary</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Action</font></td>
        <td width="20%" align="center"><font size="2" face="Arial">Delete</font></td>
      </tr>
    <%
    	while (qu1.rs.next())
        	{
    		per_id = qu1.rs.getInt("PersonID");
    		per_name = qu1.rs.getString("PersonName");
    		per_birth = qu1.rs.getString("PersonBirth");
    		per_tel = qu1.rs.getString("PersonTel");
    		per_salary = qu1.rs.getString("PersonSalary");
    
    %>
      <tr>
        <td width="20%" align="center"><%= per_id%></td>
        <td width="20%" align="center"><%= per_name%></td>
        <td width="20%" align="center"><%= per_birth%></td>
        <td width="20%" align="center"><%= per_tel%></td>
        <td width="20%" align="center"><%= per_salary%></td>
        <td width="20%" align="center"><input type="button" name="edit" value="EDIT" onclick="jump_edit('<%= per_id%>')"/></td>
        <td width="20%" align="center"><jsp:useBean id="xx" scope="session" class="com.DeleteBean">
        </jsp:useBean><a href="<jsp:getProperty name="xx" property="next"/>"><img border="0" src="images/remove.png" width="16" height="16"/></a></td>
      </tr>
    <%    
       }    
       qu1.rs.close();    
       qu1.closeConnection();
    %>
    </table>
    Bean Code is:
    Code:
     String count;
        public static String str;
        public static String url = "del.jsp?PersonID=";
    
        public void setDriverClass(String s) throws ClassNotFoundException, SQLException
        {
          str = s;
          Class.forName(driver);
          conn = DriverManager.getConnection(db_url, login_uid, login_pwd);
          stmt = conn.createStatement();
    
          rs = stmt.executeQuery(str);
        }
    
        public String getNext() throws SQLException
        {
          while(rs.next())
          {
            count = rs.getString("PersonID");
            System.out.println(count);
          }
          return url + count;
        }
    Last edited by MaxiWang; 05-19-2005 at 04:18 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links