一个jsp搜索天气预报的代码,如果数据库有就出现数据,如果没有就提示“暂时无信息”
代码:
{
sql = "select city.name, weather.date, weather.air_quality, weather.wind, weather.ultraviolet, weather.max_temperature, weather.min_temperature, weather_info.weather from weather, city, weather_info "
+" where city.code=weather.city_code and weather.weather_info=weather_info.code and quhao='"+postcode+"'";
}
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.recordcount == 0 )
{
out.println("<tr>");
out.println("<td colspan=4>暂无该信息</td>");
out.println("</tr>");
}
else
{
while(rs.next())
{
out.println("<tr>");
out.println("<td>"+rs.getString("name").toString()+"</td>");
out.println("<td>"+rs.getString("weather").toString()+"</td>");
out.println("<td>"+rs.getString("max_temperature").toString()+"</td>");
out.println("<td>"+rs.getString("min_temperature").toString()+"</td>");
out.println("</tr>");
}
pstmt.close();
conn.close();
}}catch(Exception e)
{
}
%>但是提示错误:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 117 in the jsp file: /ss-24.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Weather\org\apache\jsp\ss_002d24_jsp.java:191: cannot resolve symbol
symbol : variable recordcount
location: interface java.sql.ResultSet
if (rs.recordcount == 0 )
^
An error occurred at line: 117 in the jsp file: /ss-24.jsp
Generated servlet error:
Note: C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Weather\org\apache\jsp\ss_002d24_jsp.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
1 error很郁闷,谢谢帮助,立刻加分!!!
代码:
{
sql = "select city.name, weather.date, weather.air_quality, weather.wind, weather.ultraviolet, weather.max_temperature, weather.min_temperature, weather_info.weather from weather, city, weather_info "
+" where city.code=weather.city_code and weather.weather_info=weather_info.code and quhao='"+postcode+"'";
}
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.recordcount == 0 )
{
out.println("<tr>");
out.println("<td colspan=4>暂无该信息</td>");
out.println("</tr>");
}
else
{
while(rs.next())
{
out.println("<tr>");
out.println("<td>"+rs.getString("name").toString()+"</td>");
out.println("<td>"+rs.getString("weather").toString()+"</td>");
out.println("<td>"+rs.getString("max_temperature").toString()+"</td>");
out.println("<td>"+rs.getString("min_temperature").toString()+"</td>");
out.println("</tr>");
}
pstmt.close();
conn.close();
}}catch(Exception e)
{
}
%>但是提示错误:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 117 in the jsp file: /ss-24.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Weather\org\apache\jsp\ss_002d24_jsp.java:191: cannot resolve symbol
symbol : variable recordcount
location: interface java.sql.ResultSet
if (rs.recordcount == 0 )
^
An error occurred at line: 117 in the jsp file: /ss-24.jsp
Generated servlet error:
Note: C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Weather\org\apache\jsp\ss_002d24_jsp.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
1 error很郁闷,谢谢帮助,立刻加分!!!
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
out.println("<tr>");
out.println("<td colspan=4>暂无该信息</td>");
out.println("</tr>");
}
else
{
do
{
out.println("<tr>");
out.println("<td>"+rs.getString("name").toString()+"</td>");
out.println("<td>"+rs.getString("weather").toString()+"</td>");
out.println("<td>"+rs.getString("max_temperature").toString()+"</td>");
out.println("<td>"+rs.getString("min_temperature").toString()+"</td>");
out.println("</tr>");
}while(rs.next());
}
pstmt.close();
conn.close();