程序:
String sql3="select SendTime,Title from board where ID=";
sql3+="(select Max(ID) from board where ForumID="+forumID+")";
ResultSet board2;
board2=display.query(sql3);
if(board2!=null)
{board2.next();
%>
<td width="236" align="center"> <%=board2.getString("Title")%>( <%=board2.getTime("SendTime")%>) </td>
运行后提示:
org.apache.jasper.JasperException: Exception in JSP: /main.jsp:91 88: if(board2!=null)
89: {board2.next();
90: %>
91: <td width="236" align="center"> <%=board2.getString("Title")%>( <%=board2.getTime("SendTime")%>) </td>
92: <%
93: board2.close();
94: }
是什么异常啊?SQL语句有错误吗?错在哪?好像没有错吧!不懂!
其中SendTime在数据库里是DateTime类型.
String sql3="select SendTime,Title from board where ID=";
sql3+="(select Max(ID) from board where ForumID="+forumID+")";
ResultSet board2;
board2=display.query(sql3);
if(board2!=null)
{board2.next();
%>
<td width="236" align="center"> <%=board2.getString("Title")%>( <%=board2.getTime("SendTime")%>) </td>
运行后提示:
org.apache.jasper.JasperException: Exception in JSP: /main.jsp:91 88: if(board2!=null)
89: {board2.next();
90: %>
91: <td width="236" align="center"> <%=board2.getString("Title")%>( <%=board2.getTime("SendTime")%>) </td>
92: <%
93: board2.close();
94: }
是什么异常啊?SQL语句有错误吗?错在哪?好像没有错吧!不懂!
其中SendTime在数据库里是DateTime类型.
89: {
90: %>
91: <td width="236" align="center"> <%=board2.getString("Title")%>( <%=board2.getTime("SendTime")%>) </td>
92: <%
93:
94: }
95: board2.close();
如果数据库执行正常,不管有没有数据board2都不为空,但是board2.next()就不一定了
所以你上面的写法,如果没有取到数据,执行到board2.getString()就会报异常