upt_comm1.jsp:
<%@ page contentType="text/html; charset=GBK" %>
请输入要修改的商品的编号
type="button" value="取消" name="cancel">
upt_comm2.jsp:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
java.util.Date d = new java.util.Date();
DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
%>
<%
String sCommID = request.getParameter("comm_id");
String sCommName = "";
String sCommCate = "";
String sCommUnit = null;
String sCommQutt = null;
String sCommUptDt = null;
String sCommColor = "";
String sCommSize = "";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl???????SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
ResultSet rs = null;
String sQuery = null;
Statement stmt = null;
try {
sQuery = "select COMM_ID, COMM_NAME, COMM_CATE, COMM_UNIT, COMM_QUTT,";
sQuery = sQuery + "to_char(COMM_UPT_DATE,'yyyy-mm-dd') COMM_UPT_DATE, COMM_COLOR, COMM_SIZE ";
sQuery = sQuery + "from commodity where comm_id = '"+sCommID+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
while(rs.next())
{
sCommID = rs.getString("COMM_ID");
sCommName = rs.getString("COMM_NAME");
sCommCate = rs.getString("COMM_CATE");
if (sCommCate==null) sCommCate="";
sCommUnit = rs.getString("COMM_UNIT");
sCommQutt = rs.getString("COMM_QUTT");
sCommUptDt = rs.getString("COMM_UPT_DATE");
sCommColor = rs.getString("COMM_COLOR");
if (sCommColor==null) sCommColor="";
sCommSize = rs.getString("COMM_SIZE");
if (sCommSize==null) sCommSize="";
}
rs.close();
stmt.close();
conn.close();
}
catch (Exception e){ 检索商品信息失败!
System.out.println("检索商品信息失败!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
%>
upt_comm3.jsp:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String sCommID = request.getParameter("comm_id");
String sCommName = request.getParameter("comm_name");
String sCommCate = request.getParameter("comm_cate");
String sCommUnit = request.getParameter("comm_unit");
String sCommQutt = request.getParameter("comm_qutt");
String sCommUptDt = request.getParameter("comm_upt_date");
String sCommColor = request.getParameter("comm_color");
String sCommSize = request.getParameter("comm_size");
String sCommID2 = new String(sCommID.getBytes("iso-8859-1"),"GBK");
String sCommName2 = new String(sCommName.getBytes("iso-8859-1"),"GBK");
String sCommCate2 = new String(sCommCate.getBytes("iso-8859-1"),"GBK");
String sCommColor2 = new String(sCommColor.getBytes("iso-8859-1"),"GBK");
String sCommSize2 = new String(sCommSize.getBytes("iso-8859-1"),"GBK");
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl为你的数据库的SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
String sUpdate = null;
Statement stmt = null;
try{
sUpdate = "update commodity set comm_cate='"+sCommCate2+
"',comm_unit="+sCommUnit+
",comm_color='"+sCommColor2+
"',comm_size='"+sCommSize2+
"',comm_upt_date=to_date('"+sCommUptDt+
"','yyyy-mm-dd') where comm_id='"+sCommID2+"'";
//out.println(sUpdate+" 修改商品信息失败!
");
stmt = conn.createStatement();
stmt.execute(sUpdate);
conn.commit();
out.println("修改商品"+sCommName2+"信息完成");
}
catch(Exception e){
System.out.println("修改商品信息失败!");
e.printStackTrace();
out.println("
out.println( e.getMessage() );
out.println("");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
%>