Hi,
I created a
jsp,
servlet and a mysql db. There are 3 attributes : id, name and salary of the staff db. I want to sort by id, name, salary and show them in jsp page. How should I do it?
Here is the servlet:
[code]
public synchronized void SortStaff(Staff staff)throws StaffException
{
int result = 0;
java.sql.PreparedStatement pstmt = null; try
{
pstmt = conn.prepareStatement("select * from records order by id");
pstmt.setString(1,staff.getStaffName()); pstmt.setDouble(2,staff.getStaffSalary()); pstmt.setInt(3,staff.getStaffID());
result = pstmt.executeUpdate(); }
catch(SQLException se)
{
throw new StudentException("Sort Staff error");
}
finally
{
try { if(pstmt!=null)pstmt.close();}
catch (Exception e) { throw new StudentException("Sort Staff error"); }
}
if(result < 1)
throw new StudentException("Sort Staff error"); }
Moreover, how should I click sort by id, name or salary and go to the proper try block?
Thanks for help.
Andrew