Hey, this works fine if i don't close my resultset. I don't get it. I'm using it, but its at null?
<html>
<head>
<TITLE>Add a Completed Course</TITLE>
</head>
<%@ page language="java" import="java.sql.*" %>
<body>
<%
String driver = "org.postgresql.Driver";
Class.forName(driver).newInstance();
String url="jdbc:postgresql://localhost/training?user=postgres&password=postgres";
Connection con=null;
Statement stmt=null;
Statement stmt2=null;
Statement stmt3=null;
Statement stmt5=null;
ResultSet rst=null;
ResultSet rst2=null;
ResultSet rst3=null;
ResultSet rst5=null;
try{
con=DriverManager.getConnection(url);
}
catch(Exception e){
System.out.println(e.getMessage());
}
stmt=con.createStatement();
stmt2=con.createStatement();
stmt3=con.createStatement();
stmt5=con.createStatement();
//result sets
rst5=stmt5.executeQuery("select * from mperson");
String inputUsername = request.getParameter("selectEmployee");
%>
<center>
<table border="1" cellpadding="0" cellspacing="0" width="900">
<form action = "viewemptraining.jsp" method="post">
<tr><td><center><table> <td colspan="2" align="center">
<tr><td><h2>View Courses</h2><br></td><tr>
<td colspan="2" align="center">
<tr><td>Select Trainee's Name</td>
<td><select name= selectEmployee>
<option value = null>
<%
//dropdown box to select an employee
while(rst5.next()){
String fname=rst5.getString("firstname");
String lname=rst5.getString("lastname");
String pid=rst5.getString("loginid");
out.println("<option value ="+pid+">");
out.println(fname+" "+lname);
}
out.println("</select></td></tr><tr><td><br></td></tr>");
out.println("<tr><td></td><td><input type='submit' value='Submit' /></tr></td></table></center></form></table>");
//This is where the actual report starts
if(request.getParameter("selectEmployee")==null){
//rst=stmt.executeQuery("select * from mperson");
//rst2=stmt2.executeQuery("select * from mperson");
rst3=stmt3.executeQuery("select * from mperson");
}
else{
out.println("<center><h1>Individual Training Report </h1></center>");
rst=stmt.executeQuery("select cu.currdesc from curricula cu, employee_curricula ec, mperson mp where ec.currid=cu.currid and mp.personid=ec.empid and mp.loginid='"+inputUsername+"'");
while(rst.next()){
String curricstuff = rst.getString("currdesc");
out.println(curricstuff);
//query to get the curriculum and completed training
rst2 = stmt2.executeQuery("select cu.currdesc, co.coursedesc from curriculacourses cc, mperson mp, courses co, curricula cu, completed_training ct where ct.courseid=co.courseid and ct.empid=mp.personid and cc.courseid=ct.courseid and cc.currid=cu.currid and cu.currdesc='"+curricstuff+"' and mp.loginid='"+inputUsername+"'");
//query to get the curriculum and incomplete training
rst3 = stmt3.executeQuery("select cu.currdesc, co.coursedesc from employee_curricula ec, mperson mp, curricula cu, courses co, curriculacourses cc where cc.currid=ec.currid and ec.currid=cu.currid and cc.courseid=co.courseid and ec.empid=mp.personid and cu.currdesc='"+curricstuff+"' and mp.loginid='"+inputUsername+"' except select cu.currdesc, co.coursedesc from curriculacourses cc, mperson mp, courses co, curricula cu, completed_training ct where ct.courseid=co.courseid and ct.empid=mp.personid and cc.courseid=ct.courseid and cc.currid=cu.currid and cu.currdesc='"+curricstuff+"' and mp.loginid='"+inputUsername+"'");
}
}
/*
//close resultsets, statements and database connection
rst5.close();
stmt5.close();
rst.close();
stmt.close();
con.close();
%>
</center>
</body>
</html>
Edited by: DuudeBoston on Sep 26, 2008 6:58 AM
Hey sorry. Just to let you know, here is the error.
org.apache.jasper.JasperException: Exception in JSP: /viewemptraining.jsp:128
125:
126: rst5.close();
127: stmt5.close();
128: rst.close();
129: stmt.close();
130: con.close();