Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 20th, 2006, 09:55 AM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help my code is not giving me a result set

Please help my code is not giving me a result set for the search criteria ?
this is a bean i have written for the search criteria also attached is the code for the JSP page

Code:
 package diamx.admin; 
import java.io.*; 
import java.sql.*; 
import java.util.*; 

public class GuestData { 
   private Connection connection; 
   private Statement statement; 

   // construct TitlesBean object 
   public GuestData() throws Exception 
   { 
      // load the Cloudscape driver 
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 

      // connect to the database 
     connection = DriverManager.getConnection( 
                "jdbc:odbc:diamx"); 

     statement = connection.createStatement(); 




   } 

  public List getGuestList() throws SQLException 
   { 
   //String track=guest.getTrackingNo("track"); 
      List guestList = new ArrayList(); 
GuestBean guest = new GuestBean(); 
      // obtain list of titles 
      String query="SELECT * FROM customer WHERE trackingNo='"+guest.getTrackingNo+"'"; 
ResultSet results = statement.executeQuery(query); 
while ( results.next() ) { 


         guest.setFirstname(results.getString(1)); 
         guest.setLastname(results.getString(2)); 
         guest.setTrackingNo(results.getString(3)); 
         guest.setParcel(results.getString(4)); 
         guest.setDestination(results.getString(5)); 
         guest.setAddress(results.getString(6)); 
         guest.setStatus(results.getString(7)); 
         guest.setReceiversname(results.getString(8)); 
         guest.setTimereceived(results.getString(9)); 
         guest.setDatereceived(results.getString(10)); 

          guestList.add( guest ); 
      }          
    return guestList; 
   } 


       protected void finalize() 
   { 
      // attempt to close database connection 
      try { 
        statement.close(); 

         connection.close(); 
      } 

      // process SQLException on close operation 
      catch ( SQLException sqlException ) { 
         sqlException.printStackTrace(); 
      } 
   }}
.
This is the jsp page code

Code:
<html xmlns = "http://www.w3.org/1999/xhtml"> 

   <head> 
      <title>Customer data</title> 

       <link rel = "stylesheet" href = "styles.css" 
         type = "text/css" /> 
   </head> 

   <body> 
      <p style = "font-size: 2em;">Customer Details</p> 

      <table> 
         <thead> 
            <tr> 
               <th style = "width: 100px;">Last name</th> 
               <th style = "width: 100px;">First name</th> 
               <th style = "width: 200px;">Tracking No</th> 
               <th style = "width: 100px;">Type of Parcel</th> 
               <th style = "width: 100px;">Destination</th> 
               <th style = "width: 300px;">Address</th> 
               <th style = "width: 100px;">Status</th> 
               <th style = "width: 100px;">Recievers Name</th> 
               <th style = "width: 200px;">Time Recieved</th> 
                <th style = "width: 200px;">Date Recieved</th> 
            </tr> 
         </thead> 

         <tbody> 

        <% // start scriptlet 

            List guestList = guestData.getGuestList(); 
            Iterator guestListIterator = guestList.iterator(); 
            GuestBean guest; 

            while ( guestListIterator.hasNext() ) { 
               guest = ( GuestBean ) guestListIterator.next(); 

         %> <%-- end scriptlet; insert fixed template data --%> 

               <tr> 
                  <td><%= guest.getFirstname() %></td> 

                  <td><%= guest.getLastname() %></td> 

                  <td> 

                        <%= guest.getTrackingNo() %></a> 
                  </td> 
                  <td><%= guest.getParcel() %></td> 

                  <td><%= guest.getDestination() %></td> 

                  <td> 

                        <%= guest.getAddress() %></a> 
                  </td> 
                  <td><%= guest.getStatus() %></td> 

                  <td><%= guest.getReceiversname() %></td> 

                  <td> 

                        <%= guest.getTimereceived() %></a> 
                  </td> 
                   <td><%= guest.getDatereceived() %></td> 
               </tr> 

         <% // continue scriptlet 

            } // end while 

         %> <%-- end scriptlet --%> 

         </tbody> 
      </table> 
   </body> 

</html>


stay alive





Similar Threads
Thread Thread Starter Forum Replies Last Post
ExecuteNonQuery not giving proper result Lalit Pradhan ASP.NET 2.0 Professional 6 July 24th, 2008 02:00 AM
getting a result set to a vector cakalanka Java Databases 1 March 24th, 2008 07:33 AM
This piece of code is giving an error sourik C# 2 July 15th, 2006 09:18 AM
write result set bmains SQL Server 2000 11 March 9th, 2004 09:31 AM
Result set jemacc SQL Server 2000 0 December 19th, 2003 07:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.