小弟用JSP做一个简单的系统,要实现添加删除修改功能,用JAVABEAN连接数据库,已经成功,添加也已经实现,目前在删除上遇到了问题,点击删除按纽,转跳到删除页面,在数据库test中有表A表B,从中各取数据显示在删除页面的表单上,我是这样写的,各位看看那错了:
<body topmargin="0" bgcolor=lightyellow>
<br>
<div align="center"><font size=12 color="red"><b>警告!</b></font></div>
<br>
<div ><font size=5 color="#3333FF"><strong>您正在试图删除如下记录:</strong></font></div>
<br><%String mbid=request.getParameter("mbid");
String awdid=request.getParameter("awdid");
String nm=new String(request.getParameter("nm").getBytes("ISO8859_1"));
String awdnm=new String(request.getParameter("awdnm").getBytes("ISO8859_1"));DBall_bean.Connect(); //连接数据库,//
//连接查询语句//
String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid
from awd_info,member_info2,awdtp_info
where awd_info.mbid = member_info2.mbid,awdtp_info.awdid = awd_info.awdid; "
ResultSet rs=DBall_bean.executeQuery(query);
if (rs.next())
{
%>
<form id="form3" name="info3" method="post" action="D_awd_info.jsp?mbid=<%=mbid%>&awdid=<%=awdid%>">
<div align="center">
<table width="534" height="229" border="1" cellpadding="1" cellspacing="0" bgcolor="#CCCCFF">
<tr>
<td width="129" height="41"><div align="center"><font color="#FF6600"><strong>姓名</strong></font></div></td>
<td width="395"><%=nm%> </td>
</tr>
<tr>
<td height="37"><div align="center"><font color="#FF6600"><strong>获奖名称</strong></font></div></td>
<td height="37"><%=awdnm%> </td>
</tr>
<tr>
<td height="36"><div align="center"><font color="#FF6600"><strong>授予时间</strong></font></div></td>
<td height="36"><%=rs.getString("awddt")%> </td>
</tr>
<tr>
<td height="38"><div align="center"><font color="#FF6600"><strong>批准机关</strong></font></div></td>
<td height="38"><%=rs.getString("auth")%> </td>
</tr>
<tr>
<td height="36"><div align="center"><font color="#FF6600"><strong>先进事迹</strong></font></div></td>
<td height="36"><%=rs.getString("awdnt")%> </td>
</tr>
<tr>
<td height="39" colspan="2"><div align="center">
<input type="submit" name="Submit2" value="确定">
<input type="button" name="Submit2" value="返回"onClick="javascript:history.go(-1);return true;">
</div></td>
</tr>
</table>
</div>
</form>
<%}
DBall_bean.Close();
%>
</body>
</html>
<body topmargin="0" bgcolor=lightyellow>
<br>
<div align="center"><font size=12 color="red"><b>警告!</b></font></div>
<br>
<div ><font size=5 color="#3333FF"><strong>您正在试图删除如下记录:</strong></font></div>
<br><%String mbid=request.getParameter("mbid");
String awdid=request.getParameter("awdid");
String nm=new String(request.getParameter("nm").getBytes("ISO8859_1"));
String awdnm=new String(request.getParameter("awdnm").getBytes("ISO8859_1"));DBall_bean.Connect(); //连接数据库,//
//连接查询语句//
String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid
from awd_info,member_info2,awdtp_info
where awd_info.mbid = member_info2.mbid,awdtp_info.awdid = awd_info.awdid; "
ResultSet rs=DBall_bean.executeQuery(query);
if (rs.next())
{
%>
<form id="form3" name="info3" method="post" action="D_awd_info.jsp?mbid=<%=mbid%>&awdid=<%=awdid%>">
<div align="center">
<table width="534" height="229" border="1" cellpadding="1" cellspacing="0" bgcolor="#CCCCFF">
<tr>
<td width="129" height="41"><div align="center"><font color="#FF6600"><strong>姓名</strong></font></div></td>
<td width="395"><%=nm%> </td>
</tr>
<tr>
<td height="37"><div align="center"><font color="#FF6600"><strong>获奖名称</strong></font></div></td>
<td height="37"><%=awdnm%> </td>
</tr>
<tr>
<td height="36"><div align="center"><font color="#FF6600"><strong>授予时间</strong></font></div></td>
<td height="36"><%=rs.getString("awddt")%> </td>
</tr>
<tr>
<td height="38"><div align="center"><font color="#FF6600"><strong>批准机关</strong></font></div></td>
<td height="38"><%=rs.getString("auth")%> </td>
</tr>
<tr>
<td height="36"><div align="center"><font color="#FF6600"><strong>先进事迹</strong></font></div></td>
<td height="36"><%=rs.getString("awdnt")%> </td>
</tr>
<tr>
<td height="39" colspan="2"><div align="center">
<input type="submit" name="Submit2" value="确定">
<input type="button" name="Submit2" value="返回"onClick="javascript:history.go(-1);return true;">
</div></td>
</tr>
</table>
</div>
</form>
<%}
DBall_bean.Close();
%>
</body>
</html>
解决方案 »
- SiteMesh在weblogic10下部署中文乱码
- 求助,数组赋值错误。
- 高分求 jsp sql server2000~~b/s进销存管理系统
- 烦人的打印,一起讨论,来者有分
- 如何在网页中对下拉列表select进行编程
- 请教:struts中jsp页面问题
- 我做的第一个BEAN编译过了,可是不能执行大家帮忙侃侃。谢谢。
- 关于北京或上海工作情况的调查,欢迎讨论
- servlet类库在Jbuilder中能运行起来吗(如果不配置相关的服务器端解释器)
- jq prop('checked',true) 无效怎么处理啊?
- web日历,直接把在日历上选中的日期输入到text里面去,有这样的组件吗?
- 如何传递超连接参数
逗号改成and
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: 22 in the jsp file: /add/O_awd_info.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\dangyuan\add\O_awd_info_jsp.java:98: unclosed string literal
String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid
^
An error occurred at line: 22 in the jsp file: /add/O_awd_info.jspGenerated servlet error:
D:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\dangyuan\add\O_awd_info_jsp.java:100: unclosed string literal
where awd_info.mbid = member_info2.mbid and awdtp_info.awdid = awd_info.awdid ";
^
2 errors
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper
郁闷,分号有什么错误?
你的String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid……这句有错误,每行代码都要有分号做结束符的
String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid
^An error occurred at line: 22 in the jsp file: /add/O_awd_info.jspGenerated servlet error:
D:\TOMCAT\Tomcat 4.1\work\Standalone\localhost\dangyuan\add\O_awd_info_jsp.java:100: unclosed string literal
where awd_info.mbid = member_info2.mbid and awdtp_info.awdid = awd_info.awdid ";
^
2 errors
显示的有问题,提示select语句开头和末尾的分号出错
的100行
******为你的表
from awd_info,member_info2,awdtp_info
where awd_info.mbid = member_info2.mbid and awdtp_info.awdid = awd_info.awdid ";
此句中 ="" 两个引号有错,不知道怎么回事,粘贴的话 ^ 位置不对,实际是指向两个引号的
String query="…… 吧?
把你的sql语句写出来,赋给query变量不就行了
member_info2 中有nm
awdtp_info 中有awdnm 查询这两个列的值显示在删除表单的页面中就完成了
select=" …… ?????????
String query="…… 吧?
把你的sql语句写出来,赋给query变量不就行了
==============================================
是啊,我正是这个意思,我是这样写的:
String query=" select member_info2.nm, awdtp_info.awdnm, awd_info.mbid, awd_info.awdid
from awd_info,member_info2,awdtp_info
where awd_info.mbid = member_info2.mbid and awdtp_info.awdid = awd_info.awdid ";
//以上是查询语句,以下是边历结果集//
ResultSet rs=DBall_bean.executeQuery(query);
String awdid=request.getParameter("awdid");
这两个是不是要传给query里的参数?如果是就在sqlWhere中加上
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Column not found
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
at org.apache.jsp.O_awd_info_jsp._jspService(O_awd_info_jsp.java:209)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
................
root cause
java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1852)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
...............
表的列名是不是写错了?和数据库里对应一下
看看O_awd_info_jsp.java的209行附近
mbid 是member_info2表的主键,对应着member表中的nm 也就是姓名
awdid是awdtp_info表的主键, 对应着awdtp表中的awdnm 也就是获奖名称
是这样加的吗?:String query = sqlSelect + sqlFrom + sqlWhere + mbid + awdid;
如果你的两个列的类型是字符型的话要加单引号,如下
String sqlWhere = " where awdtp_info.mbid='"+awdid+"' and member_info2.awdid='"+mbid+"' and awd_info.mbid = member_info2.mbid and awdtp_info.awdid = awd_info.awdid ";