Hi, i cant seem to get DB2 data to display on my JSP page. Is it because of my coding or because for the db2driver? Attached below is a copy of my class file.
public void close() throws SQLException{
dbCon.close();
}
//accepts the SQL query in the form of a string from the JSP file in which this bean is implemented
public ResultSet execSQL(String sql) throws SQLException{
System.out.println("haha");
//initiates the connection with the dbCon connection object
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}
public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}
}
<jsp:useBean id="DbConnectBean1" scope="page" class="WH.DbConnect1" />
<%
//Get status
/*String message;
String status = request.getParameter("status").trim();
if (status == "duplicateEmail")
message="Please try again. An account with the same emaill address has already been created.";
else if (status == "deleteOk")
message="Delete successful.";
else
message="";*/
if (r.next()==false)
{
%>
<tr>
<td colspan="7">There are no records currently.</td>
</tr>
<% }
}//end if%>
<tr colspan="6">
<td>
<%//=message%> <input type="submit" name="btnDelete" value="Delete">
</td>
</tr>
</table>
</form>
</body>
</html>
You'll get a better response if you post something more descriptive about what you can't do.
- Is the code compiling? If not, what's the error message?
- Is there a runtime exception? If so, what's the error message?
- Is your page not displaying information? What should it be doing, and what's happening instead?
Also, it's best to try and filter your code down to the essential elements that you're having problems with. The amount that you've posted isn't going to be scanned through by a lot of people.