Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 20th, 2006, 09:55 AM
Registered User
 
Join Date: Sep 2006
Location: yaba, lagos, Nigeria.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:15 PM.


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