An error occurred at line: 250 in the jsp file: /index.jspGenerated servlet error: [javac] Compiling 1 source fileD:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:441: cannot resolve symbol symbol : variable stmt location: class org.apache.jsp.index_jsp if(stmt!=null) stmt.close(); ^An error occurred at line: 250 in the jsp file: /index.jspGenerated servlet error: D:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:441: cannot resolve symbol symbol : variable stmt location: class org.apache.jsp.index_jsp if(stmt!=null) stmt.close(); ^An error occurred at line: 250 in the jsp file: /index.jspGenerated servlet error: D:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:442: cannot resolve symbol symbol : variable conn location: class org.apache.jsp.index_jsp conn.close(); ^ 3 errorsIE中的错误是这样显示的!
if(rs!=null)
{
rs.close();
}
if(stmt!=null)
{
stmt.close();
}
if(con!=null)
{
con.close();
}
}catch(Exception e){}
}
try{
String url="jdbc:odbc:SELLSYSTEM";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(url,"","");
Statement stmt=conn.createStatement();
String sql="select * from NEWS order by PUBLIC_DATE desc";
ResultSet rs=stmt.executeQuery(sql);
while((rs.next())&&(i<10)){%>
<tr>
<td width="30" height="20" align="right"><img src="./picture/3dot.gif"></td>
<td> </td>
<td><span class="style5"><%=rs.getString("NEWS_TITLE")%></span> <span class="style6"><%=rs.getDate("PUBLIC_DATE")%></span></td>
</tr>
<%}
}
catch(Exception e){
throw(e);
}
try{
if(stmt!=null) stmt.close();
conn.close();
}
catch(Exception e){}%>
这是全部的代码!
请指教!
其实不难,就是你的jsp页面中有些例如(); ""之类的位置写的是中文输入法下的符号,而不是英文输入法下的符号
你仔细检查一下
我昨天遇到的问题跟你一模一样
[javac] Compiling 1 source fileD:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:441: cannot resolve symbol
symbol : variable stmt
location: class org.apache.jsp.index_jsp
if(stmt!=null) stmt.close();
^An error occurred at line: 250 in the jsp file: /index.jspGenerated servlet error:
D:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:441: cannot resolve symbol
symbol : variable stmt
location: class org.apache.jsp.index_jsp
if(stmt!=null) stmt.close();
^An error occurred at line: 250 in the jsp file: /index.jspGenerated servlet error:
D:\eclipse\workspace\Exec\work\org\apache\jsp\index_jsp.java:442: cannot resolve symbol
symbol : variable conn
location: class org.apache.jsp.index_jsp
conn.close();
^
3 errorsIE中的错误是这样显示的!
然后用jcreator编译,看提示的错误信息Statement stmt=conn.createStatement();与if(stmt!=null) stmt.close();
没有出现在同一个try-catch中,把后者删掉
if(stmt!=null) stmt.close();
conn.close();
}
catch(Exception e){}
注释掉试试
<%
try{
String url="jdbc:odbc:SELLSYSTEM";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(url,"","");
Statement stmt=conn.createStatement();
String sql="select * from NEWS order by PUBLIC_DATE desc";
ResultSet rs=stmt.executeQuery(sql);
while((rs.next())&&(i<10)){%>
<tr>
<td width="30" height="20" align="right"><img src="./picture/3dot.gif"></td>
<td> </td>
<td><span class="style5"><%=rs.getString("NEWS_TITLE")%></span> <span class="style6"><%=rs.getDate("PUBLIC_DATE")%></span></td>
</tr>
<%}
if(stmt!=null) stmt.close();
conn.close();
}
catch(Exception e){
throw(e);
}%>但是谁能告诉我为什么?
Statement stmt=conn.createStatement();与if(stmt!=null) stmt.close();
放在同一个try-catch中,就可以了!
为什么?
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<%
int i=9;
try{
String url="jdbc:mysql://localhost/guwan";
Class.forName("org.gjt.mm.mysql.Driver");
Connection conn=DriverManager.getConnection(url,"root","");
Statement stmt=conn.createStatement();
String sql="select * from certificate";
ResultSet rs=stmt.executeQuery(sql);
while((rs.next())&&(i<10)){%>
<tr>
<td width="30" height="20" align="right"><img src="./picture/3dot.gif"></td>
<td> </td>
<td><span class="style5"><%=rs.getString("certificate_type")%></span></td>
</tr>
<%}
}
catch(Exception e){
throw(e);
}
/*try{
if(stmt!=null) stmt.close();
conn.close();
}
catch(Exception e){}
*/
%>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<%Statement stmt=null;
Connection conn=null;
try{
String url="jdbc:odbc:SELLSYSTEM";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection(url,"","");
stmt=conn.createStatement();
String sql="select * from NEWS order by PUBLIC_DATE desc";
ResultSet rs=stmt.executeQuery(sql);
while((rs.next())&&(i<10)){%>
<tr>
<td width="30" height="20" align="right"><img src="./picture/3dot.gif"></td>
<td> </td>
<td><span class="style5"><%=rs.getString("certificate_type")%></span></td>
</tr>
<%}
}
catch(Exception e){
throw(e);
}
try{
if(stmt!=null) stmt.close();
conn.close();
}
catch(Exception e){}%>