码迷,mamicode.com
首页 > 其他好文 > 详细

按键三,2,按条件 输入数据后

时间:2017-12-13 02:23:08      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:div   tin   connect   com   head   desc   public   page   输入数据   

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP ‘update_stu_3.jsp‘ starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<title>修改后重写记录页面</title>

<body>
<%
String driverName="com.mysql.jdbc.Driver";
String dbName="MyLogin";
String userName="root";
String userPwd="lovezjl";
String url1="jdbc:mysql://localhost:3306/MyLogin";
String url2="?user=root&password=lovezjl";
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url);



String sushe3=request.getParameter("sushe");
String shuliang3=request.getParameter("shuliang2");
String jiedan3=request.getParameter("jiedan2");
String song3=request.getParameter("song2");
String sql="update student_xinxi1 set shuliang=?,jiedan=?,song=? where sushe=‘"+sushe3+"‘";
PreparedStatement pstmt=conn.prepareStatement(sql);
request.setCharacterEncoding("UTF-8");
pstmt.setString(1,shuliang3);
pstmt.setString(2,jiedan3);
pstmt.setString(3,song3);
int n=pstmt.executeUpdate();
if(n>=1){%>重写数据操作成功!<br><%}
else{ %>重写数据操作失败!<% %><br><%}
if(pstmt!=null){pstmt.close();}
if(conn!=null){conn.close();}
%>





</body>

</html>

按键三,2,按条件 输入数据后

标签:div   tin   connect   com   head   desc   public   page   输入数据   

原文地址:http://www.cnblogs.com/lozjl/p/8030157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!