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

POS管理系统之供应商查询

时间:2014-08-16 09:41:50      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:http   java   os   io   for   ar   art   cti   

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 
    <title>My JSP ‘LoginServlet.jsp‘ starting page</title>
   
  </head>
 
  <body>
        <form action="<%=request.getContextPath()%>/mfrEdit1.do" method="post">
     <table border="1">
      <tr>
       <td>厂商代码</td>
       <td><input type="text" name="cno">
       <input type="hidden" name="method" value="find"/>
       </td>
      </tr>
      <tr>
       <td>
       <input type="submit" value="查询"/>
       </td>
      </tr>
      </table>
    </form>
  </body>
</html>

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Cusinfo;

@SuppressWarnings("serial")
public class EditServlet1 extends HttpServlet{
 private final String URL="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
 private final String USER="gsuser";
 private final String PWD="160127";
 
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
  
  doPost(req, resp);
 }

 @Override
 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
  req.setCharacterEncoding("utf-8");
      String cno=req.getParameter("cno");
    int i = deletemfrEdit(cno);
    if (i > 0) {
     // 删除成功了
     resp.sendRedirect(req.getContextPath() + "/Success.jsp");
    } else {
     resp.sendRedirect("http://www.sohu.com");
    }

}
 private int deletemfrEdit(String cno) {
  String delete= "DELETE FROM MFREDIT A WHERE A.CNO=?";
  int i = 0;
  // 加载驱动
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  }
  Connection conn = null;
  PreparedStatement pstmt = null;
  try {
   conn = DriverManager.getConnection(URL, USER, PWD);
   pstmt = conn.prepareStatement(delete);
   // 设置参数
   pstmt.setString(1, cno);
   //pstmt.setString(2, cname);   // 执行
   i = pstmt.executeUpdate();
  } catch (SQLException e) {
   e.printStackTrace();
  }finally {
   try {
   if (pstmt != null) {
    pstmt.close();
   }
   if (conn != null) {
    conn.close();
   }
  } catch (SQLException e) {
   e.printStackTrace();
  }
 }
  return i;
 }

POS管理系统之供应商查询,布布扣,bubuko.com

POS管理系统之供应商查询

标签:http   java   os   io   for   ar   art   cti   

原文地址:http://www.cnblogs.com/fanweichao/p/3916006.html

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