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