Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 JSP连接数据库出现问题,向大家请教,谢谢!
Bluebluesea





发贴: 6
于 2007-04-12 22:59 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
JSP中连接数据库又出现了问题,向大家请教
(deletepro.jsp):
id 类别 名称 出厂商 价格 描述 删除 (表格字段)
dddd english ddddd dddddd 22.0 ddddd 删除 (表格内容)
isbn-4-6 computer J2EE企业级应用开发 电子工业出版 56.0 还不错 删除 (表格内容)
现在是想点表格内容中的"删除"就可以转向"deletepro_do.jsp"实现删除其一行
比如点第一个表格内容中的删除,则删除id="dddd"的一行,"id"是主键
deletepro.jsp主要代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="db" scope="page" class="demo.openDB" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>删除商品</title>
<style type="text/css">
<!--
.STYLE2 {color: #FFFFFF}
-->
</style>
</head>
<body>
<br><br><br>
<center>
<font size="+5" face="华文隶书">删除一个商品</font>
</center>
<br><br><br><br>
<center>
<table bgcolor="#FF6666">
<tr>
<td width="100">id</td>
<td width="100" align="center">类别</td>
<td width="200" align="center">名称</td>
<td width="150" align="center">出厂商</td>
<td width="100" align="center">价格</td>
   <td width="150" align="center">描述</td>
   <td width="50" align="center">删除</td>
</tr>
<%
Connection conn=db.getConnection();
String sql="select * from products";
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
%>
<tr>
<td bgcolor="#FFDD33"><%=rs.getString("productid")%></td>
<td bgcolor="#FFFF00"><%=rs.getString("category")%></td>
<td bgcolor="#99CC00"><%=rs.getString("name")%></td>
<td bgcolor="#FFCC99"><%=rs.getString("producer")%></td>
   <td bgcolor="#88FFDD"><%=rs.getFloat("price")%></td>
   <td bgcolor="#DDFC88"><%=rs.getString("descn")%></td>
<td bgcolor="#6633FF" align="center"><span class="STYLE2"><a href="deletepro_do.jsp">
删除</a></span></td>
  </tr>
<%}%>
</table>
<br>
<br><br><br>
<a href="goodmain.jsp">返回</a>
</center>
</body>
</html>
deletepro_do.jsp主要代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="db" scope="page" class="demo.openDB" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>删除商品</title>
<style type="text/css">
<!--
.STYLE2 {color: #FFFFFF}
-->
</style>
</head>
<body>
<br><br><br>
<center>
<font size="+5" face="华文隶书">删除一个商品</font>
</center>
<br><br><br><br>
<%
String id=request.getParameter(Products);
Connection conn=db.getConnection();
Statement stmt=conn.createStatement();
String sql="delete from products where productid='"+id+"'";
stmt.executeUpdate(sql);
%>
<% response.sendRedirect("deletepro.jsp");%>
</body>
</html>
其中的JAVABEAN是用来连接数据库的,没错的
现在问题是点了表格内容中的删除还是删不掉那一行,请大家帮忙,我是新手,希望大家赐教




话题树型展开
人气 标题 作者 字数 发贴时间
2169 JSP连接数据库出现问题,向大家请教,谢谢! Bluebluesea 2747 2007-04-12 22:59
1764 Re:JSP连接数据库出现问题,向大家请教,谢谢! cxp108 63 2007-04-13 09:12
1776 Re:JSP连接数据库出现问题,向大家请教,谢谢! Bluebluesea 71 2007-04-13 14:07
1693 Re:JSP连接数据库出现问题,向大家请教,谢谢! chengbd 187 2007-04-15 15:51
1797 Re:JSP连接数据库出现问题,向大家请教,谢谢! zhangsf1982 105 2007-04-25 13:24

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923