库存物资管理系统代码,详细过程和总结

库存物资管理系统实验要求如下:

1.背景资料

1、有一个存放商品的仓库,每天都有商品出库和入库。
2、每种商品都有名称、生产厂家、型号、规格等。
3、出入库时必须填写出入库单据,单据包括商品名称、生产厂家、型号、
规格、数量、日期、时间、入库单位(或出库单位)名称、送货(或提货)人
姓名。
2.系统要求与功能设计
2.1页面要求
(1)能够在Tomcat服务器中正确部署,并通过浏览器查看;(1分)
(2)网站页面整体风格统一;
2.2设计要求
1、设计出入库单据的录入。
2、实现按商品名称、出入库日期的查询。

3.评分标准:
1、A类:完全实现上述功能,达到A类标准的同学可以免于参加期末上机考试,
期末上机考试成绩按满分计算。
2、B类:实现出入库单据记录的添加。
3、C类:实现数据库的连接。
4、D类:不满足上述要求的。

详细过程:1.刚拿到题目,觉得貌似比上次的简单,因为看题目要求的篇幅并不多,但看完题后,思考编写的过程发现并不简单,题目能给的关键信息点太少;

2.首先编写必要的jsp界面,自己懒得写,是课前在网上见过的类似界面代码修改而成的,想省下点时间写关键的方法代码;

3.商品信息的录入和查询通过上次实验的学习已经基本掌握了,但是也费了半天时间弄,主要是不太熟悉,有些东西也是修改代码完成的;

4.接下来就是最头疼的那个出库,有点懵,我一开始想是不是还用考虑往外取物资的系统,瞎编了半天没结果,马上就快下机了,然后听说是没那么复杂,就是相当于上次学生管理系统的修改步骤,想着A标已经无妄了,就回宿舍参考了上次的那个系统又改了快一个多小时,终于磕磕巴巴的做出了个粗糙的程序。

总结:上次靠学长的代码完完全全的实现了功能,觉得下一次做系统应该差不多了,没想到只是按照人家的思路可以做下来,自己做一个新的系统,一些类似的死的东西道是没问题,出了个出库就直接懵了,还是缺乏自己的独立思考,不过这次就是同学提醒了一下思路就自己完成了,还算有进步了,时间花费比较多,以后要加快速度。

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
    .a{
        margin-top: 20px;
    }
    .b{
        font-size: 20px;
        width: 160px;
        color: white;
        background-color: greenyellow;
    }
</style>
</head>
<body>
    <%
         Object message = request.getAttribute("message");
         if(message!=null && !"".equals(message)){

    %>
         <script type="text/javascript">
              alert("<%=request.getAttribute("message")%>");
         </script>
    <%} %>
    <div align="center">
        <h1 style="color: red;">商品入库</h1>
        <a href="index.jsp">返回主页</a>
        <form action="UserServlet?method=add" method="post" onsubmit="return check()">
            <div class="a">
                分类名<input type="text" name="name" />
            </div>
            <div class="a">
                                厂家<input type="text" name="changjia" />
            </div>
            <div class="a">
                型号<input type="text" name="xinghao"/>
            </div>
            <div class="a">
                规格<input type="text" name="guige"/>
            </div>
            <div class="a">
                数量<input type="text" name="shuliang" />
            </div>
            <div class="a">
                日期<input type="text" name="riqi" />
            </div>
            <div class="a">
                单位名称<input type="text" name="danwei" />
            </div>
            <div class="a">
                人名<input type="text" name="xingming"/>
            </div>
            <div class="a">
                操作<input type="text" name="caozuo"/>
            </div>
            <div class="a">
                <input type="submit" value="添加" onClick="delcfm1()" />
            </div>
        </form>
    </div>
     <script language="javascript">
    function delcfm1() {
        if (!confirm("确认要添加?")) {
            window.event.returnValue = false;
        }
    }
   </script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
    .a{
        margin-top: 20px;
    }
    .b{
        font-size: 20px;
        width: 160px;
        color: white;
        background-color: greenyellow;
    }
</style>
</head>
<body>
    <%
         Object message = request.getAttribute("message");
         if(message!=null && !"".equals(message)){

    %>
         <script type="text/javascript">
              alert("<%=request.getAttribute("message")%>");
         </script>
    <%} %>
    <div align="center">
        <h1 style="color: red;">删除</h1>
        <a href="index.jsp">返回主页</a>
        <form action="UserServlet?method=getuserbyname" method="post" onsubmit="return check()">
            <div class="a">
                商品名称<input type="text" name="name" />
            </div>
            <div class="a">
                <button type="submit" class="b">查&nbsp;&nbsp;&nbsp;找</button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        function check() {
            var name = document.getElementByName("name");;

            //非空
            if(name.value == ‘‘) {
                alert(‘商品名称为空‘);
                name.focus();
                return false;
            }
        }
    </script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
    .a{
        margin-top: 20px;
    }
    .b{
        font-size: 20px;
        width: 160px;
        color: white;
        background-color: greenyellow;
    }
    .tb, td {
        border: 1px solid black;
        font-size: 22px;
    }
</style>
</head>
<body>
    <div align="center">
        <h1 style="color: red;"></h1>
        <a href="index.jsp">返回主页</a>
        <table class="tb">
            <tr>
                <td>商品名称</td>
                <td>${user.name}</td>
            </tr>
            <tr>
                <td>商品厂家</td>
                <td>${user.changjia}</td>
            </tr>
            <tr>
                <td>商品型号</td>
                <td>${user.xinghao}</td>
            </tr>
                        <tr>
                <td>商品规格</td>
                <td>${user.guige}</td>
            </tr>
                        <tr>
                <td>商品数量</td>
                <td>${user.shuliang}</td>
            </tr>
                        <tr>
                <td>日期</td>
                <td>${user.riqi}</td>
            </tr>
                        <tr>
                <td>单位</td>
                <td>${user.danwei}</td>
            </tr>
                        <tr>
                <td>姓名</td>
                <td>${user.xingming}</td>
            </tr>
            <tr>
                <td>操作</td>
                <td>${user.caozuo}</td>
            </tr>
        </table>
        <div class="a">
            <a onclick="return check()" href="UserServlet?method=del&name=${user.name}">删&nbsp;&nbsp;&nbsp;除</a>
        </div>
    </div>
    <script type="text/javascript">
        function check() {
            if (confirm("真的要删除吗?")){
                return true;
            }else{
                return false;
            }
        }
    </script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
    .a{
        font-size: 26px;
        margin-top: 20px;
    }
</style>
</head>
<body>
    <div align="center">
        <h1 style="color: red;">库存物资管理</h1>
        <div class="a">
            <a href="add.jsp">商品出入库</a>
        </div>
        <div class="a">
            <a href="del.jsp">商品的删除</a>
        </div>
        <div class="a">
            <a href="search.jsp">查询</a>
        </div>
    </div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
    .a{
        margin-top: 20px;
    }
    .b{
        font-size: 20px;
        width: 160px;
        color: white;
        background-color: greenyellow;
    }
    .tb, td {
        border: 1px solid black;
        font-size: 22px;
    }
</style>
</head>
<body>
    <%
         Object message = request.getAttribute("message");
         if(message!=null && !"".equals(message)){

    %>
         <script type="text/javascript">
              alert("<%=request.getAttribute("message")%>");
         </script>
    <%} %>
    <div align="center">
        <h1 style="color: red;">商品信息列表</h1>
        <a href="index.jsp">返回主页</a>
            <form action="UserServlet?method=getuserbyname" method="post" onsubmit="return check()">
            <div class="a">
                商品名称<input type="text" name="name" />
            </div>
            <div class="a">
                <button type="submit" class="b">查&nbsp;&nbsp;&nbsp;找</button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        function check() {
            var name = document.getElementById("name");;

            //非空
            if(name.value == ‘‘) {
                alert(‘商品名称为空‘);
                name.focus();
                return false;
            }
        }
    </script>
</body>
</html>
package com.jaovo.msg.dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.jaovo.msg.model.User;
import com.jaovo.msg.Util.DBUtil;
public class Dao {

    public boolean add(User user) {
        String sql = "insert into user( name, changjia,xinghao,guige,shuliang,riqi,danwei,xingming,caozuo) values(‘" + user.getName() + "‘,‘" + user.getChangjia() + "‘,‘" + user.getXinghao() + "‘,‘" + user.getGuige() + "‘,‘" + user.getShuliang() + "‘,‘" + user.getRiqi() +"‘,‘" + user.getDanwei() +"‘,‘" + user.getXingming()  +"‘,‘" + user.getCaozuo()+"‘)";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        boolean f = false;
        int a = 0;
        try {
            state = conn.createStatement();
            state.executeUpdate(sql);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(state, conn);
        }

        if (a > 0) {
            f = true;
        }
        return f;
    }

    public boolean delete (String name) {
        boolean f = false;
        String sql = "delete from user where name=‘" + name + "‘";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        int a = 0;
        try {
            state = conn.createStatement();
            a = state.executeUpdate(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(state, conn);
        }

        if (a > 0) {
            f = true;
        }
        return f;
    }

    public boolean update(User user) {
        String sql = "update user set guige=‘"+user.getGuige()+ "‘, changjia=‘" + user.getChangjia() + "‘, xinghao=‘" + user.getXinghao()+ "‘, shuliang=‘" + user.getShuliang() +"‘, riqi=‘" + user.getRiqi() +"‘, danwei=‘" + user.getDanwei()+"‘, xingming=‘" + user.getXingming()  +"‘, caozuo=‘" + user.getCaozuo() +"‘where name=‘" + user.getName() + "‘";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        boolean f = false;
        int a = 0;

        try {
            state = conn.createStatement();
            a = state.executeUpdate(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(state, conn);
        }

        if (a > 0) {
            f = true;
        }
        return f;
    }

    public boolean name(String name) {
        boolean flag = false;
        String sql = "select name from user where name = ‘" + name + "‘";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            while (rs.next()) {
                flag = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }

    public User getUserByName(String name) {
        String sql = "select * from user where name =‘" + name + "‘";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;
        User user= null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            while (rs.next()) {
                String name1 = rs.getString("name");
                String changjia= rs.getString("changjia");
                String xinghao= rs.getString("xinghao");
                String guige =rs.getString("guige");
                String shuliang=rs.getString("shuliang");
                String riqi=rs.getString("riqi");
                String danwei=rs.getString("danwei");
                 String xingming=rs.getString("xingming");
                 String caozuo=rs.getString("caozuo");
                user = new User(name1,changjia,xinghao,guige,shuliang,riqi,danwei,xingming,caozuo);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }

        return user;
    }

    public List<User> search(String name,String changjia,String xinghao,String guige,String shuliang,String riqi,String danwei,String xingming ) {
        String sql = "select * from user where ";
        if (name != "") {
            sql += "name like ‘%" + name + "%‘";
        }
        if (changjia!= "") {
            sql += "changjia like ‘%" + changjia + "%‘";
        }
        if (xinghao != "") {
            sql += "xinghao like ‘%" + xinghao+ "%‘";
        }
        if (guige != "") {
            sql += "guige like ‘%" + guige+ "%‘";
        }
        if (shuliang != "") {
            sql += "shuliang like ‘%" + shuliang + "%‘";
        }
        if (riqi != "") {
            sql += "riqi like ‘%" + riqi + "%‘";
        }
        if (danwei != "") {
            sql += "danwei like ‘%" + danwei+ "%‘";
        }
        if (xingming != "") {
            sql += "xingming like ‘%" + xingming + "%‘";
        }
        List<User> list = new ArrayList<>();
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            User bean = null;
            while (rs.next()) {
                String name1 = rs.getString("name");
                String changjia1= rs.getString("changjia");
                String xinghao1= rs.getString("xinghao");
                String guige1 =rs.getString("guige");
                String shuliang1=rs.getString("shuliang");
                String riqi1=rs.getString("riqi");
                String danwei1=rs.getString("danwei");
                 String xingming1=rs.getString("xingming");
                 String caozuo=rs.getString("caozuo");
                bean = new User(name1,changjia1,xinghao1,guige1,shuliang1,riqi1,danwei1,xingming1,caozuo);
                list.add(bean);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }

        return list;
    }

    public List<User> list() {
        String sql = "select * from user";
        List<User> list = new ArrayList<>();
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            User bean = null;
            while (rs.next()) {
                String name = rs.getString("name");
                String changjia= rs.getString("changjia");
                String xinghao= rs.getString("xinghao");
                String guige =rs.getString("guige");
                String shuliang=rs.getString("shuliang");
                String riqi=rs.getString("riqi");
                String danwei=rs.getString("danwei");
                String xingming=rs.getString("xingming");
                 String caozuo=rs.getString("caozuo");
                bean= new User(name,changjia,xinghao,guige,shuliang,riqi,danwei,xingming,caozuo);
                list.add(bean);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }

        return list;
    }

}
package com.jaovo.msg.model;
import java.sql.Connection;
public class User {
    private String name;
    private String changjia;
    private String xinghao;
    private String guige;
    private String shuliang;
    private String riqi;
    private String danwei;
    private String xingming;
    private String caozuo;
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public String getChangjia() {
        return changjia;
    }
    public void setChangjia(String changjia) {
        this.changjia = changjia;
    }
    public String getXinghao() {
        return xinghao;
    }
    public void setXinghao(String xinghao) {
        this.xinghao = xinghao;
    }
    public String getGuige() {
        return guige;
    }
    public void setGuige(String guige) {
        this.guige = guige;
    }
    public String getShuliang() {
        return shuliang;
    }
    public void setShuliang(String shuliang) {
        this.shuliang = shuliang;
    }
    public String getRiqi() {
        return riqi;
    }
    public void setRiqi(String riqi) {
        this.riqi = riqi;
    }
    public String getDanwei() {
        return danwei;
    }
    public void setDanwei(String danwei) {
        this.danwei = danwei;
    }
    public String getXingming() {
        return xingming;
    }
    public void setXingming(String xingming) {
        this.xingming = xingming;
    }
    public User(String name,String changjia,String xinghao,String guige,String shuliang,String riqi,String danwei,String xingming ,String caozuo) {
        this.name = name;
        this.changjia = changjia;
        this.xinghao = xinghao;
        this.guige = guige;
        this.shuliang = shuliang;
        this.riqi = riqi;
        this.danwei = danwei;
        this.xingming = xingming;
        this.setCaozuo(caozuo);
    }
    public User() {
        // TODO Auto-generated constructor stub
    }
    public String getCaozuo() {
        return caozuo;
    }
    public void setCaozuo(String caozuo) {
        this.caozuo = caozuo;
    }

}
package com.jaovo.msg.service;
import java.util.List;
import com.jaovo.msg.dao.Dao;
import com.jaovo.msg.model.User;
public class UserService {
    Dao cDao = new Dao();
    public boolean add(User user) {
        boolean f = false;
        if(!cDao.name(user.getName())) {
            cDao.add(user);
            f = true;
        }
        return f;
    }
    public void del(String  name) {
        cDao.delete(name);
    }
    public void update(User user) {
        cDao.update(user);
    }
    public User getUserByName(String name) {
        return cDao.getUserByName(name);
    }

    public List<User> search(String name ) {
        return (List<User>) cDao.getUserByName(name);
    }
    public List<User> list() {
        return cDao.list();
    }
}
package com.jaovo.msg.severlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jaovo.msg.model.User;
import com.jaovo.msg.service.UserService;
@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    UserService service = new UserService();

    /**
     * 鏂规硶閫夋嫨
     */
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String method = req.getParameter("method");
        if ("add".equals(method)) {
            add(req, resp);
        } else if ("del".equals(method)) {
            del(req, resp);
        } else if ("update".equals(method)) {
            update(req, resp);
        } else if ("search".equals(method)) {
            search(req, resp);
        }        else if ("getuserbyname".equals(method)) {
            getUserByName(req, resp);
        } else if ("list".equals(method)) {
            list(req, resp);
        }
    }

    /**
     * 娣诲姞
     * @param <service>
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException
     */
    private <service> void add(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        String changjia= req.getParameter("changjia");
        String xinghao=req.getParameter("xinghao");
        String guige =req.getParameter("guige");
        String shuliang=req.getParameter("shuliang");
        String riqi=req.getParameter("riqi");
        String danwei=req.getParameter("danwei");
        String xingming=req.getParameter("xingming");
        String caozuo=req.getParameter("caozuo");
        User user = new User(name,changjia,xinghao,guige,shuliang,riqi,danwei,xingming,caozuo);

        //娣诲姞鍚庢秷鎭樉绀?
        if(service.add(user)) {
            req.setAttribute("message", "娣诲姞鎴愬姛");
            req.getRequestDispatcher("add.jsp").forward(req,resp);
        } else {
            req.setAttribute("message", "鍟嗗搧鍚嶇О閲嶅锛岃閲嶆柊褰曞叆");
            req.getRequestDispatcher("add.jsp").forward(req,resp);
        }
    }

    /**
     * 鍏ㄩ儴
     * @param req
     * @param resp
     * @throws ServletException
     */
    private void list(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        List<User> users = service.list();
        req.setAttribute("users", users);
        req.getRequestDispatcher("list.jsp").forward(req,resp);
    }

    /**
     * 閫氳繃鍚嶅瓧鏌ユ壘
     * 璺宠浆鑷冲垹闄?
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException
     */
    private void getUserByName(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        User user = service.getUserByName(name);
        if(user == null) {
            req.setAttribute("message", "鏌ユ棤姝ゅ晢鍝侊紒");
            req.getRequestDispatcher("del.jsp").forward(req,resp);
        } else {
            req.setAttribute("user", user);
            req.getRequestDispatcher("detail.jsp").forward(req,resp);
        }
    }
    /**
     * 鍒犻櫎
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException
     */
    private void del(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        service.del(name);
        req.setAttribute("message", "鍒犻櫎鎴愬姛锛?");
        req.getRequestDispatcher("del.jsp").forward(req,resp);
    }

    /**
     * 淇敼
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException
     */
    private void update(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        String changjia= req.getParameter("changjia");
        String xinghao=req.getParameter("xinghao");
        String guige =req.getParameter("guige");
        String shuliang=req.getParameter("shuliang");
        String riqi=req.getParameter("riqi");
        String danwei=req.getParameter("danwei");
        String xingming=req.getParameter("xingming");
        String caozuo=req.getParameter("caozuo");
        User user = new User(name,changjia,xinghao,guige,shuliang,riqi,danwei,xingming,caozuo);
        service.update(user);
        req.setAttribute("message", "淇敼鎴愬姛");
        req.getRequestDispatcher("").forward(req,resp);
    }

    /**
     * 鏌ユ壘
     * @param req
     * @param resp
     * @throws ServletException
     */
    private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        String changjia= req.getParameter("changjia");
        String xinghao= req.getParameter("xinghao");
        String guige =req.getParameter("guige");
        String shuliang=req.getParameter("shuliang");
        String riqi=req.getParameter("riqi");
        String danwei=req.getParameter("danwei");
        String xingming=req.getParameter("xingming");
        List<User> users = service.search(name);
        req.setAttribute("users", users);
        req.getRequestDispatcher("searchlist.jsp").forward(req,resp);
    }
}
package com.jaovo.msg.Util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 鏁版嵁搴撹繛鎺ュ伐鍏?
 * @author Hu
 *
 */
public class DBUtil {

    public static String db_url = "jdbc:mysql://localhost:3306/runoob?useUnicode=true&characterEncoding=utf-8";
    public static String db_user = "root";
    public static String db_pass = "root";

    public static Connection getConn () {
        Connection conn = null;

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");//鍔犺浇椹卞姩
            conn = DriverManager.getConnection(db_url, db_user, db_pass);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return conn;
    }

    /**
     * 鍏抽棴杩炴帴
     * @param state
     * @param conn
     */
    public static void close (Statement state, Connection conn) {
        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close (ResultSet rs, Statement state, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

}

原文地址:https://www.cnblogs.com/cuijunfeng/p/10117179.html

时间: 2024-11-13 06:49:24

库存物资管理系统代码,详细过程和总结的相关文章

库存物资管理系统(过关测试)

实验要求: 1..有一个存放商品的仓库,每天都有商品出库和入库. 2.每种商品都有名称.生产厂家.型号.规格等. 3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号.规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人姓名. 通过这次实验,我发现数据库的增删改查实验可以经由一个基本模板去演变,这样不但减少了工作量,同时使错误减少. 下面是此次测试的截图和代码 1 <%@ page language="java" import="java.u

库存物资管理系统

package com.hjf.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * 数据库连接工具 * @author Hu * */ public class DBUti

库存物资管理系统-测试

实验要求: 1..有一个存放商品的仓库,每天都有商品出库和入库. 2.每种商品都有名称.生产厂家.型号.规格等. 3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号.规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人姓名. 建两张数据表,一张用来商品的增删改查,一张记录商品的出库与入库信息 所用及代码: public class GoodsBean { private String name; private String type; private String

【javaweb】库存物资管理系统思路与总结

题目: 1.有一个存放商品的仓库,每天都有商品出库和入库. 2.每种商品都有名称.生产厂家.型号.规格等. 3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号. 规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人 姓名. 首先建立数据库goodsmanager table:goods记录商品信息 table:list记录出入库信息 Java部分: 先把页面写好 首页面用<iframe>分为左侧导航栏,和右侧页面 点击左侧超链接即可实现右侧页面的跳转,在left.

网站渗透测试原理及详细过程

网站渗透测试原理及详细过程 渗透测试(Penetration Testing)目录 零.前言一.简介二.制定实施方案三.具体操作过程四.生成报告五.测试过程中的风险及规避参考资料FAQ集 零.前言 渗透测试在未得到被测试方授权之前依据某些地区法律规定是违法行为. 这里我们提供的所有渗透测试方法均为(假设为)合法的评估服务,也就是通常所说的道德黑客行为(Ethical hacking),因此我们这里的所有读者应当都是Ethical Hackers,如果您还不是,那么我希望您到过这里后会成为他们中的

UCOS2_STM32F1移植详细过程(二)

Ⅰ.概述 打开上一篇文章新建的工程,是提取的ST标准库里面源代码文件和UCOS工程包源代码文件.下载过的朋友可能会知道,直接编译那个工程会有大片的错误和警告,原因在于那个工程是没有经过修改源代码的工程,接下来就是讲述一步一步修改源代码的过程(也就是所谓的移植过程). 该文接着上一篇文章来讲述“UCOS移植详细过程”,上一篇文章是讲述准备工作.文件提取并整理.新建UCOS工程等工作.该文讲述UCOS移植过程中修改源代码(底层代码.系统配置等)工作. 笔者将“UCOS移植详细过程”分为多篇文章来讲述

UCOS2_STM32F1移植详细过程(一)

Ⅰ.概述 该文写针对初学µC/OS的朋友,基于以下平台来一步一步移植µC/OS嵌入式操作系统.UCOS移植相关平台: 系统平台:µC/OS-II  (最新V2.92版) 硬件平台:STM32F1   (适合F1所以系列) 开发平台:Keil(MDK-ARM) V5 1.为什么是µC/OS-II? 原因在于µC/OS-II是一个比较成熟.稳定的系统,与µC/OS-III比较有些机制相对简单很多.当你掌握了µC/OS-II,µC/OS-III很容易就理解了. 2.为什么是STM32F1? 硬件平台是

STM32F0xx_TIM输出PWM配置详细过程

前言 前面我说过STM32的定时器功能很强大,今天就来总结一下它的另外一个“强大”功能:TIM的比较输出功能,输出可调PWM波形.直接调用函数接口“TIM2_CH1_PWM(uint32_t Freq, uint16_t Dutycycle)”传入频率和占空比就能输出指定的波形. 我提供的软件工程直接调用是比较简单就能实现想要的PWM波形.但是,如果你是学习者,建议还是进去函数把每一个细节了解清楚,里面的东西可能对你掌握TIM很有帮助. 本着免费分享的原则,如果你觉得分享的内容对你有用,认可我分

第一部分:使用iReport制作报表的详细过程(Windows环境下)

提示:在有些板块,文中的图片看不到,建议到我的blog浏览文章:http://blog.csdn.net/jemlee2002/文章将会涉及3个方面的内容: 第二部分:使用Jasperreport作为报表控件开发胖客户端报表应用 第三部分:使用Jasperreport作为报表控件开发Web报表应用 1.前言 在网络上可以搜索到很多使用iReport和Jasperreport配合实现各种报表任务的文章,但是我觉得很少有一篇(几乎没有)做一个比较详细的介绍如何使用iReport制作报表的全过程,我所