friend.jsp
<b><br>通讯录一览表</b>
<table width="450" border="0" cellpadding="1" bgcolor="#000000">
<tr><th bgcolor="#FFFFFF" scope="col">编号</th>
<th bgcolor="#FFFFFF" scope="col">姓名</th>
<th bgcolor="#FFFFFF" scope="col">电话</th></tr>
<%! ResultSet rs=null; %>
<%
int type=-1;
try{
type=Integer.parseInt(request.getParameter("do"));
}
catch(Exception eee) {type=0;}
try{
Statement st=getStatement();
String name=request.getParameter("name");
switch(type){
case 0:
rs=st.executeQuery("select * from friends");
break;
case 1:
name=new String(name.getBytes("ISO-8859-1"));
st.executeUpdate("delete from friends where name='"+name+"'");
response.sendRedirect("friend.jsp");
break;
case 3:
name=new String(name.getBytes("ISO-8859-1"));
String tel=request.getParameter("tel");
st.executeUpdate("insert friends values('0','"+name+"','"+tel+"')");
response.sendRedirect("friend.jsp");
break;
case 4:
name=new String(name.getBytes("ISO-8859-1"))
tel=request.getParameter("tel");
String sql="update friends set tel='"+tel+"' where name='"+name+"'";
st.executeUpdate(sql);
response.sendRedirect("friend.jsp");
break;
}
%>
<%
while(rs.next()){
%>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
<%}
rs.close();
st.close();
}catch(Exception ee) {out.print(ee.toString());} %>
</table>
<form id="form1" name="form1" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="1" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit" value="查询" /></div>
</form>
<form id="form2" name="form2" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="2" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit2" value="删除" /></div> </form>
<form id="form3" name="form3" method="post" action="friend.jsp">
<input type="hidden" name="do" value="3" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit22" value="添加" /></p></form>
<form id="form4" name="form4" method="post" action="friend.jsp">
<input type="hidden" name="do" value="4" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit222" value="修改" /></p></form>
<%!
public Statement getStatement(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=friend";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
//Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return con.createtatement();
}catch(Exception e) {return null;}}
%>
28 个解决方案
#1
连接sql数据库 数据库名:friend.表名friends.包含三字段id(int),name(char),tel(char)
#2
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /data/683/friend.jsp
ResultSet cannot be resolved to a type
3: <tr><th bgcolor="#FFFFFF" scope="col">编号</th>
4: <th bgcolor="#FFFFFF" scope="col">姓名</th>
5: <th bgcolor="#FFFFFF" scope="col">电话</th></tr>
6: <%! ResultSet rs=null; %>
7:
8:
9: <%
An error occurred at line: 83 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
80:
81:
82: <%!
83: public Statement getStatement(){
84: try{
85:
86: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
Connection cannot be resolved to a type
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
DriverManager cannot be resolved
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 92 in the jsp file: /data/683/friend.jsp
con cannot be resolved
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
94: %>
95:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
The method getStatement() is undefined for the type friend_jsp
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 20 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
20: rs=st.executeQuery("select * from friends");
21: break;
22: case 1:
23: name=new String(name.getBytes("ISO-8859-1"));
An error occurred at line: 34 in the jsp file: /data/683/friend.jsp
Syntax error, insert ";" to complete Statement
31: response.sendRedirect("friend.jsp");
32: break;
33: case 4:
34: name=new String(name.getBytes("ISO-8859-1"))
35: tel=request.getParameter("tel");
36: String sql="update friends set tel='"+tel+"' where name='"+name+"'";
37: st.executeUpdate(sql);
An error occurred at line: 45 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
42:
43:
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
An error occurred at line: 47 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
An error occurred at line: 48 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
An error occurred at line: 49 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
An error occurred at line: 51 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
53: }catch(Exception ee) {out.print(ee.toString());} %>
54: </table>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /data/683/friend.jsp
ResultSet cannot be resolved to a type
3: <tr><th bgcolor="#FFFFFF" scope="col">编号</th>
4: <th bgcolor="#FFFFFF" scope="col">姓名</th>
5: <th bgcolor="#FFFFFF" scope="col">电话</th></tr>
6: <%! ResultSet rs=null; %>
7:
8:
9: <%
An error occurred at line: 83 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
80:
81:
82: <%!
83: public Statement getStatement(){
84: try{
85:
86: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
Connection cannot be resolved to a type
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
DriverManager cannot be resolved
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 92 in the jsp file: /data/683/friend.jsp
con cannot be resolved
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
94: %>
95:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
The method getStatement() is undefined for the type friend_jsp
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 20 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
20: rs=st.executeQuery("select * from friends");
21: break;
22: case 1:
23: name=new String(name.getBytes("ISO-8859-1"));
An error occurred at line: 34 in the jsp file: /data/683/friend.jsp
Syntax error, insert ";" to complete Statement
31: response.sendRedirect("friend.jsp");
32: break;
33: case 4:
34: name=new String(name.getBytes("ISO-8859-1"))
35: tel=request.getParameter("tel");
36: String sql="update friends set tel='"+tel+"' where name='"+name+"'";
37: st.executeUpdate(sql);
An error occurred at line: 45 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
42:
43:
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
An error occurred at line: 47 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
An error occurred at line: 48 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
An error occurred at line: 49 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
An error occurred at line: 51 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
53: }catch(Exception ee) {out.print(ee.toString());} %>
54: </table>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
--------------------------------------------------------------------------------
#3
在线等,有人吗?
#4
判断一下再close
#5
看的眼花缭乱,俺可以回家洗洗睡了
#6
我试着去看了一下楼主的代码。。那一个累淫啊。。。
大哥。。可以理成mvc么?
Syntax error, insert ";" to complete Statement,34行那里也少了个;号了
大哥。。可以理成mvc么?
Syntax error, insert ";" to complete Statement,34行那里也少了个;号了
#7
<%! ResultSet rs=null; %>
多了个!,估计其他地方也多了个!,把JAVA代码写在JSP上不是个好习惯,一般JSP页面只是处理数据结果。
多了个!,估计其他地方也多了个!,把JAVA代码写在JSP上不是个好习惯,一般JSP页面只是处理数据结果。
#8
全部在jsp页面,我了个去,眼花缭乱。。。。。。
#9
6: <%
! ResultSet rs=null; %>
还有很多问题是没有导入包。
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
con应该是conn
注意细节。
还有很多问题是没有导入包。
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
con应该是conn
注意细节。
#10
没有引入sql包.
在jsp的最上面加上这句
<%@ page import="java.util.sql" %>
在jsp的最上面加上这句
<%@ page import="java.util.sql" %>
#11
看得我一个累。。
最好页面不要嵌入JAVA代码。。
最好页面不要嵌入JAVA代码。。
#12
我是个初学者,请问不把java代码写在jsp上那写在哪?如何实现功能?
#13
不好意思,我是初学者,页面不嵌入JAVA代码,那我如何在IE上实现以上功能?
#14
楼主:
现在的WEB开发都采用MVC的分层结构,用不用框架暂且不说,怎么着也得用Jsp+Servlet+Javabean的模式吧,建议你买一本Web开发方面的书,系统的学一下。
现在的WEB开发都采用MVC的分层结构,用不用框架暂且不说,怎么着也得用Jsp+Servlet+Javabean的模式吧,建议你买一本Web开发方面的书,系统的学一下。
#15
改过后还是出现以下错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 94 in the jsp file: /data/friend.jsp
The method createtatement() is undefined for the type Connection
91: String password="";
92: Connection con= DriverManager.getConnection(url,user,password);
93: //Statement stmt1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
94: return con.createtatement();
95: }
96: catch(Exception e) {return null;}
97: }
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 94 in the jsp file: /data/friend.jsp
The method createtatement() is undefined for the type Connection
91: String password="";
92: Connection con= DriverManager.getConnection(url,user,password);
93: //Statement stmt1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
94: return con.createtatement();
95: }
96: catch(Exception e) {return null;}
97: }
#16
有人帮忙吗?问题还未解决.还有15楼的莫名错误.想不到哪里出问题
#17
不是java.util.sql,是java.sql.*
所以改成
<%@ page import=" java.sql.*;" %>
#18
改了也不行
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*,java.util.*,java.io.*" %>
<b><br>通讯录一览表</b>
<table width="450" border="0" cellpadding="1" bgcolor="#000000">
<tr><th bgcolor="#FFFFFF" scope="col">编号</th>
<th bgcolor="#FFFFFF" scope="col">姓名</th>
<th bgcolor="#FFFFFF" scope="col">电话</th></tr>
<% ResultSet rs=null; %>
<%
int type=-1;
try{
type=Integer.parseInt(request.getParameter("do"));
}
catch(Exception eee) {type=0;}
try{
Statement st=getStatement();
String name=request.getParameter("name");
switch(type){
case 0:
rs=st.executeQuery("select * from friends");
break;
case 1:
name=new String(name.getBytes("ISO-8859-1"));
st.executeUpdate("delete from friends where name='"+name+"'");
response.sendRedirect("friend.jsp");
break;
case 3:
name=new String(name.getBytes("ISO-8859-1"));
String tel=request.getParameter("tel");
st.executeUpdate("insert friends values('0','"+name+"','"+tel+"')");
response.sendRedirect("friend.jsp");
break;
case 4:
name=new String(name.getBytes("ISO-8859-1"));
tel=request.getParameter("tel");
String sql="update friends set tel='"+tel+"' where name='"+name+"'";
st.executeUpdate(sql);
response.sendRedirect("friend.jsp");
break;
}
%>
<%
while(rs.next()){
%>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
<%}
rs.close();
st.close();
}catch(Exception ee) {out.print(ee.toString());} %>
</table>
<form id="form1" name="form1" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="1" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit" value="查询" /></div>
</form>
<form id="form2" name="form2" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="2" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit2" value="删除" /></div> </form>
<form id="form3" name="form3" method="post" action="friend.jsp">
<input type="hidden" name="do" value="3" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit22" value="添加" /></p></form>
<form id="form4" name="form4" method="post" action="friend.jsp">
<input type="hidden" name="do" value="4" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit222" value="修改" /></p></form>
<%!
public Statement getStatement(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
//Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return conn.createtatement();
}
catch(Exception e) {return null;}
}
%>
#19
//Statement stmt1=conn.
createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return conn. createtatement();
红色地方写错了,对照绿色地方看看!!
return conn. createtatement();
红色地方写错了,对照绿色地方看看!!
#20
你的这些错误 要是写在个类里 IDE都能提示你了
#21
什么IDE? eclipse等开发平台吗? 请明示,我是新手
#22
IDE 百度一下吧,很多问题都是....怎么说呢,去百度吧.
#23
还没搞定?
#24
createStatement
#25
还没搞定?就是return conn.createtatement();写错了
改成return conn.createStatement();就好了啊
改成return conn.createStatement();就好了啊
#26
搞掂了,不好意思各位,工作忙没及时上来,我想问下20楼说的是什么意思?有朋友回答下吗?回答左马上结贴给分.什么IDE? eclipse等开发平台吗?
#27
就是eclipse之类的集成开发工具 你这些方法名字写错、没引入包的问题,eclipse不是都会有红色错误提示么
#28
The method createtatement() is undefined for the type Connection
如果是这个问题,很明显是你这个createtatement() 方法有问题。
不要遇到问题就来问,自己查查,看看Connection 这个里面有没有这个方法,这个方法是干什么用的。
不然下次这个错误,你还不知道如何解决。 这个方法名你写错了。多查查API。找到Connection 这个类
看看人家写的帮助文档。希望对你有用。
如果是这个问题,很明显是你这个createtatement() 方法有问题。
不要遇到问题就来问,自己查查,看看Connection 这个里面有没有这个方法,这个方法是干什么用的。
不然下次这个错误,你还不知道如何解决。 这个方法名你写错了。多查查API。找到Connection 这个类
看看人家写的帮助文档。希望对你有用。
#1
连接sql数据库 数据库名:friend.表名friends.包含三字段id(int),name(char),tel(char)
#2
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /data/683/friend.jsp
ResultSet cannot be resolved to a type
3: <tr><th bgcolor="#FFFFFF" scope="col">编号</th>
4: <th bgcolor="#FFFFFF" scope="col">姓名</th>
5: <th bgcolor="#FFFFFF" scope="col">电话</th></tr>
6: <%! ResultSet rs=null; %>
7:
8:
9: <%
An error occurred at line: 83 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
80:
81:
82: <%!
83: public Statement getStatement(){
84: try{
85:
86: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
Connection cannot be resolved to a type
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
DriverManager cannot be resolved
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 92 in the jsp file: /data/683/friend.jsp
con cannot be resolved
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
94: %>
95:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
The method getStatement() is undefined for the type friend_jsp
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 20 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
20: rs=st.executeQuery("select * from friends");
21: break;
22: case 1:
23: name=new String(name.getBytes("ISO-8859-1"));
An error occurred at line: 34 in the jsp file: /data/683/friend.jsp
Syntax error, insert ";" to complete Statement
31: response.sendRedirect("friend.jsp");
32: break;
33: case 4:
34: name=new String(name.getBytes("ISO-8859-1"))
35: tel=request.getParameter("tel");
36: String sql="update friends set tel='"+tel+"' where name='"+name+"'";
37: st.executeUpdate(sql);
An error occurred at line: 45 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
42:
43:
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
An error occurred at line: 47 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
An error occurred at line: 48 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
An error occurred at line: 49 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
An error occurred at line: 51 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
53: }catch(Exception ee) {out.print(ee.toString());} %>
54: </table>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /data/683/friend.jsp
ResultSet cannot be resolved to a type
3: <tr><th bgcolor="#FFFFFF" scope="col">编号</th>
4: <th bgcolor="#FFFFFF" scope="col">姓名</th>
5: <th bgcolor="#FFFFFF" scope="col">电话</th></tr>
6: <%! ResultSet rs=null; %>
7:
8:
9: <%
An error occurred at line: 83 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
80:
81:
82: <%!
83: public Statement getStatement(){
84: try{
85:
86: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
Connection cannot be resolved to a type
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 90 in the jsp file: /data/683/friend.jsp
DriverManager cannot be resolved
87: String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
88: String user="sa";
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
An error occurred at line: 92 in the jsp file: /data/683/friend.jsp
con cannot be resolved
89: String password="";
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
93: }catch(Exception e) {return null;}}
94: %>
95:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
Statement cannot be resolved to a type
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 16 in the jsp file: /data/683/friend.jsp
The method getStatement() is undefined for the type friend_jsp
13: }
14: catch(Exception eee) {type=0;}
15: try{
16: Statement st=getStatement();
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
An error occurred at line: 20 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
17: String name=request.getParameter("name");
18: switch(type){
19: case 0:
20: rs=st.executeQuery("select * from friends");
21: break;
22: case 1:
23: name=new String(name.getBytes("ISO-8859-1"));
An error occurred at line: 34 in the jsp file: /data/683/friend.jsp
Syntax error, insert ";" to complete Statement
31: response.sendRedirect("friend.jsp");
32: break;
33: case 4:
34: name=new String(name.getBytes("ISO-8859-1"))
35: tel=request.getParameter("tel");
36: String sql="update friends set tel='"+tel+"' where name='"+name+"'";
37: st.executeUpdate(sql);
An error occurred at line: 45 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
42:
43:
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
An error occurred at line: 47 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
44: <%
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
An error occurred at line: 48 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
45: while(rs.next()){
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
An error occurred at line: 49 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
46: %>
47: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
An error occurred at line: 51 in the jsp file: /data/683/friend.jsp
rs cannot be resolved
48: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
49: <tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
50: <%}
51: rs.close();
52: st.close();
53: }catch(Exception ee) {out.print(ee.toString());} %>
54: </table>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
--------------------------------------------------------------------------------
#3
在线等,有人吗?
#4
判断一下再close
#5
看的眼花缭乱,俺可以回家洗洗睡了
#6
我试着去看了一下楼主的代码。。那一个累淫啊。。。
大哥。。可以理成mvc么?
Syntax error, insert ";" to complete Statement,34行那里也少了个;号了
大哥。。可以理成mvc么?
Syntax error, insert ";" to complete Statement,34行那里也少了个;号了
#7
<%! ResultSet rs=null; %>
多了个!,估计其他地方也多了个!,把JAVA代码写在JSP上不是个好习惯,一般JSP页面只是处理数据结果。
多了个!,估计其他地方也多了个!,把JAVA代码写在JSP上不是个好习惯,一般JSP页面只是处理数据结果。
#8
全部在jsp页面,我了个去,眼花缭乱。。。。。。
#9
6: <%
! ResultSet rs=null; %>
还有很多问题是没有导入包。
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
con应该是conn
注意细节。
还有很多问题是没有导入包。
90: Connection conn= DriverManager.getConnection(url,user,password);
91: //Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
92: return con.createtatement();
con应该是conn
注意细节。
#10
没有引入sql包.
在jsp的最上面加上这句
<%@ page import="java.util.sql" %>
在jsp的最上面加上这句
<%@ page import="java.util.sql" %>
#11
看得我一个累。。
最好页面不要嵌入JAVA代码。。
最好页面不要嵌入JAVA代码。。
#12
我是个初学者,请问不把java代码写在jsp上那写在哪?如何实现功能?
#13
不好意思,我是初学者,页面不嵌入JAVA代码,那我如何在IE上实现以上功能?
#14
楼主:
现在的WEB开发都采用MVC的分层结构,用不用框架暂且不说,怎么着也得用Jsp+Servlet+Javabean的模式吧,建议你买一本Web开发方面的书,系统的学一下。
现在的WEB开发都采用MVC的分层结构,用不用框架暂且不说,怎么着也得用Jsp+Servlet+Javabean的模式吧,建议你买一本Web开发方面的书,系统的学一下。
#15
改过后还是出现以下错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 94 in the jsp file: /data/friend.jsp
The method createtatement() is undefined for the type Connection
91: String password="";
92: Connection con= DriverManager.getConnection(url,user,password);
93: //Statement stmt1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
94: return con.createtatement();
95: }
96: catch(Exception e) {return null;}
97: }
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 94 in the jsp file: /data/friend.jsp
The method createtatement() is undefined for the type Connection
91: String password="";
92: Connection con= DriverManager.getConnection(url,user,password);
93: //Statement stmt1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
94: return con.createtatement();
95: }
96: catch(Exception e) {return null;}
97: }
#16
有人帮忙吗?问题还未解决.还有15楼的莫名错误.想不到哪里出问题
#17
不是java.util.sql,是java.sql.*
所以改成
<%@ page import=" java.sql.*;" %>
#18
改了也不行
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*,java.util.*,java.io.*" %>
<b><br>通讯录一览表</b>
<table width="450" border="0" cellpadding="1" bgcolor="#000000">
<tr><th bgcolor="#FFFFFF" scope="col">编号</th>
<th bgcolor="#FFFFFF" scope="col">姓名</th>
<th bgcolor="#FFFFFF" scope="col">电话</th></tr>
<% ResultSet rs=null; %>
<%
int type=-1;
try{
type=Integer.parseInt(request.getParameter("do"));
}
catch(Exception eee) {type=0;}
try{
Statement st=getStatement();
String name=request.getParameter("name");
switch(type){
case 0:
rs=st.executeQuery("select * from friends");
break;
case 1:
name=new String(name.getBytes("ISO-8859-1"));
st.executeUpdate("delete from friends where name='"+name+"'");
response.sendRedirect("friend.jsp");
break;
case 3:
name=new String(name.getBytes("ISO-8859-1"));
String tel=request.getParameter("tel");
st.executeUpdate("insert friends values('0','"+name+"','"+tel+"')");
response.sendRedirect("friend.jsp");
break;
case 4:
name=new String(name.getBytes("ISO-8859-1"));
tel=request.getParameter("tel");
String sql="update friends set tel='"+tel+"' where name='"+name+"'";
st.executeUpdate(sql);
response.sendRedirect("friend.jsp");
break;
}
%>
<%
while(rs.next()){
%>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("id") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("name") %></td>
<tr><td bgcolor="#FFFFFF"><%=rs.getInt("tel") %></td></tr>
<%}
rs.close();
st.close();
}catch(Exception ee) {out.print(ee.toString());} %>
</table>
<form id="form1" name="form1" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="1" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit" value="查询" /></div>
</form>
<form id="form2" name="form2" method="post" action="friend.jsp">
<div align="left"><input type="hidden" name="do" value="2" />
<input type="text" name="name" value="姓名" />
<input type="submit" name="Submit2" value="删除" /></div> </form>
<form id="form3" name="form3" method="post" action="friend.jsp">
<input type="hidden" name="do" value="3" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit22" value="添加" /></p></form>
<form id="form4" name="form4" method="post" action="friend.jsp">
<input type="hidden" name="do" value="4" />
<p align="left"><input type="text" name="name" value="姓名" /></p>
<p align="left"><input type="text" name="tel" value="电话" />
<input type="submit" name="Submit222" value="修改" /></p></form>
<%!
public Statement getStatement(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://192.168.10.115:1433;DatabaseName=pubs";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
//Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return conn.createtatement();
}
catch(Exception e) {return null;}
}
%>
#19
//Statement stmt1=conn.
createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
return conn. createtatement();
红色地方写错了,对照绿色地方看看!!
return conn. createtatement();
红色地方写错了,对照绿色地方看看!!
#20
你的这些错误 要是写在个类里 IDE都能提示你了
#21
什么IDE? eclipse等开发平台吗? 请明示,我是新手
#22
IDE 百度一下吧,很多问题都是....怎么说呢,去百度吧.
#23
还没搞定?
#24
createStatement
#25
还没搞定?就是return conn.createtatement();写错了
改成return conn.createStatement();就好了啊
改成return conn.createStatement();就好了啊
#26
搞掂了,不好意思各位,工作忙没及时上来,我想问下20楼说的是什么意思?有朋友回答下吗?回答左马上结贴给分.什么IDE? eclipse等开发平台吗?
#27
就是eclipse之类的集成开发工具 你这些方法名字写错、没引入包的问题,eclipse不是都会有红色错误提示么
#28
The method createtatement() is undefined for the type Connection
如果是这个问题,很明显是你这个createtatement() 方法有问题。
不要遇到问题就来问,自己查查,看看Connection 这个里面有没有这个方法,这个方法是干什么用的。
不然下次这个错误,你还不知道如何解决。 这个方法名你写错了。多查查API。找到Connection 这个类
看看人家写的帮助文档。希望对你有用。
如果是这个问题,很明显是你这个createtatement() 方法有问题。
不要遇到问题就来问,自己查查,看看Connection 这个里面有没有这个方法,这个方法是干什么用的。
不然下次这个错误,你还不知道如何解决。 这个方法名你写错了。多查查API。找到Connection 这个类
看看人家写的帮助文档。希望对你有用。