java停车场管理系统,源码,帮运行(jsp+servlet+jdbc+mysql实现),课程作业,期末项目,没有使用框架

java智能化停车场管理系统,获取方式见本文末尾


java智能化停车场管理系统,源码,帮运行(jsp+servlet+jdbc+mysql实现),可作为课程作业,期末项目等,没有使用框架,源码获取请访问扫码 http://yanzw.cn/er/about

实现技术介绍

java智能停车场管理系统,采用javaee实现,数据库采用mysql,没有使用框架,前端就是正常的html,css,js,实现比较简单,内容都是一些常见的功能

目录结构
  1. Java代码部分
    共三个包,第一个是基本类,model,第二个包是jdbc部分的实现,第三部分是servlet部分的实现
    在这里插入图片描述
  2. jsp部分
    jsp部分主要是一些前端的显示和操作,内容不复杂,很容易看懂
    在这里插入图片描述
主要页面及其实现代码
  1. 登陆
    登陆功能实现,较为简单,账户的存储没有加密,采用明文存储,查询数据库是否存在该账户,不存在返回空
    http://yanzw.cn/post/27
public boolean checkLogin(String user_id,String user_pwd)
	{
		String sqlCmd="select count(*) from user where user_id=? and user_pwd=?";//要执行的查询T-SQL命令
		Object[] objList=new Object[2];//对象数组,用来作为?参数的容器
		objList[0]=user_id;
		objList[1]=user_pwd;
		String result=SQLUtil.excuteScalar(sqlCmd,objList).toString();//执行带参数查询
		if(result.equals("1"))
		{
			return true;
		}
		else {
			return false;
		}
	}
	
  1. 具体功能示例。如获取未出停车场的车辆信息
private void getNoOut() throws ServletException, IOException
			{
				request.setCharacterEncoding("UTF-8");
				int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
				int totalPage=Integer.parseInt(fixed.getPageCount().toString()) ;//获取分页总数
				List<Object> list=fixed.getNoOut(page);//获取数据列表
				request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
				request.setAttribute("totalPage",totalPage );//将totalPage存放到request对象中,用于转发给前台页面使用
				request.getRequestDispatcher("/Admin/FixedOut.jsp").forward(request, response);//请求转发
			}

3.jsp页面示例,如登陆页面

 <form action="<%=path %>/LoginHandle" method="post" id="loginForm">
			<div class='login_fields__user' style="margin-top:10px;margin-bottom:10px;width:70%;margin-left:15%;border-bottom:1px solid rgba(255,255,255,0.5);">
				<div class='icon'>
					<img alt="" src='images/user_icon_copy.png'>
				</div>
				<input id="username" name="user_id" placeholder='用户名' maxlength="16" type='text' autocomplete="off" value="SAdmin"/>
			</div>
			<div class='login_fields__password' style="margin-bottom:10px;width:70%;margin-left:15%;border-bottom:1px solid rgba(255,255,255,0.5);">
				<div class='icon'>
					<img alt="" src='images/lock_icon_copy.png'>
				</div>
				<input id="password" name=user_pwd type="password" placeholder='密码' value="123123" maxlength="16" type='text' autocomplete="off">
			</div>
			<div class='login_fields__submit'>
				<input type='submit' value='登录' id="login">
			</div>
			</form>
  1. 演示示例
    查询停车场系统用户的相关信息
    http://yanzw.cn
    管理车位信息
    http://yanzw.cn
    管理该停车场用户信息
    http://yanzw.cn
    java停车场系统的主要菜单,里面是它的一些功能,如添加车位信息,管理车位信息,管理用户信息等
    http://yanzw.cn
MySQL数据库结构

共六个表,表的作用就如名字描述一样
http://yanzw.cn
sql代码示例

CREATE TABLE `card` (
  `card_id` varchar(50) NOT NULL,
  `seat_id` varchar(50) NOT NULL,
  `user_name` varchar(50) NOT NULL,
  `user_gender` varchar(1) NOT NULL,
  `user_addr` varchar(50) NOT NULL,
  `car_num` varchar(50) NOT NULL,
  PRIMARY KEY (`card_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `card` */
CREATE TABLE `fixed` (
  `fixed_id` varchar(50) NOT NULL,
  `card_id` varchar(50) NOT NULL,
  `entry_date` date NOT NULL,
  `entry_time` time NOT NULL,
  `out_date` date DEFAULT NULL,
  `out_time` time DEFAULT NULL,
  PRIMARY KEY (`fixed_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
下载地址

本项目具体的下载信息详见网址:http://yanzw.cn/
或者点击这里跳转
或者直接联系本文作者,联系方式见:http://yanzw.cn
或者直接点击这里跳转到本人博客
点此跳转到博客首页,扫码添加

声明:本文如有侵权,联系删除

  • 2
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
对于一个具有JSPServletJDBCMySQL技术的增删改查项目,主要有以下几个步骤: 1. 创建MySQL数据库和表格 在MySQL中创建对应的数据库和表格,以存储项目中需要的数据。 2. 编写JavaBean类 JavaBean类是用来封装表格中每一行数据的实体类。需要与表格中的每一列数据对应。 3. 编写JDBCJDBC类主要是连接MySQL数据库Java代码,实现数据库的增删改查操作。 4. 编写Servlet类 每一个增删改查页面都对应一个Servlet类,Servlet类主要是处理用户提交的请求,并跳转到相应的JSP页面。 5. 编写JSP页面 JSP页面主要是呈现数据和处理用户提交的表单数据,通过JSP页面将用户请求传递给Servlet类来实现增删改查操作。 6. 部署项目 将以上代码部署到Tomcat服务器上,并在网页中访问。 项目源码: 1. JavaBean类: ```java // User.java public class User { private int id; private String name; private int age; // Getters and Setters } ``` 2. JDBC类: ```java // JDBCUtils.java public class JDBCUtils { private static String driver = "com.mysql.cj.jdbc.Driver"; private static String url = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC"; private static String username = "root"; private static String password = "password"; public static Connection getConnection() throws Exception { Class.forName(driver); return DriverManager.getConnection(url, username, password); } public static void close(Connection conn, PreparedStatement ps, ResultSet rs) { try { if (rs != null) { rs.close(); } if (ps != null) { ps.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } } ``` 3. Servlet类: ```java // AddUserServlet.java public class AddUserServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.getParameter("name"); int age = Integer.parseInt(request.getParameter("age")); User user = new User(); user.setName(name); user.setAge(age); Connection conn = null; PreparedStatement ps = null; try { conn = JDBCUtils.getConnection(); String sql = "INSERT INTO user(name, age) VALUES(?, ?)"; ps = conn.prepareStatement(sql); ps.setString(1, user.getName()); ps.setInt(2, user.getAge()); ps.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(conn, ps, null); } response.sendRedirect(request.getContextPath() + "/list"); } } // ListUserServlet.java public class ListUserServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; List<User> userList = new ArrayList<>(); try { conn = JDBCUtils.getConnection(); String sql = "SELECT * FROM user"; ps = conn.prepareStatement(sql); rs = ps.executeQuery(); while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("name"); int age = rs.getInt("age"); User user = new User(); user.setId(id); user.setName(name); user.setAge(age); userList.add(user); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(conn, ps, rs); } request.setAttribute("userList", userList); request.getRequestDispatcher("/WEB-INF/jsp/list.jsp").forward(request, response); } } // DeleteUserServlet.java public class DeleteUserServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id = Integer.parseInt(request.getParameter("id")); Connection conn = null; PreparedStatement ps = null; try { conn = JDBCUtils.getConnection(); String sql = "DELETE FROM user WHERE id = ?"; ps = conn.prepareStatement(sql); ps.setInt(1, id); ps.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(conn, ps, null); } response.sendRedirect(request.getContextPath() + "/list"); } } // EditUserServlet.java public class EditUserServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id = Integer.parseInt(request.getParameter("id")); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; User user = new User(); try { conn = JDBCUtils.getConnection(); String sql = "SELECT * FROM user WHERE id = ?"; ps = conn.prepareStatement(sql); ps.setInt(1, id); rs = ps.executeQuery(); while (rs.next()) { String name = rs.getString("name"); int age = rs.getInt("age"); user.setId(id); user.setName(name); user.setAge(age); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(conn, ps, rs); } request.setAttribute("user", user); request.getRequestDispatcher("/WEB-INF/jsp/edit.jsp").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id = Integer.parseInt(request.getParameter("id")); String name = request.getParameter("name"); int age = Integer.parseInt(request.getParameter("age")); User user = new User(); user.setId(id); user.setName(name); user.setAge(age); Connection conn = null; PreparedStatement ps = null; try { conn = JDBCUtils.getConnection(); String sql = "UPDATE user SET name = ?, age = ? WHERE id = ?"; ps = conn.prepareStatement(sql); ps.setString(1, user.getName()); ps.setInt(2, user.getAge()); ps.setInt(3, user.getId()); ps.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(conn, ps, null); } response.sendRedirect(request.getContextPath() + "/list"); } } ``` 4. JSP页面: ```jsp <!-- add.jsp --> <form method="post" action="${pageContext.request.contextPath}/add"> <label>Name:</label> <input type="text" name="name"><br> <label>Age:</label> <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> <!-- list.jsp --> <table border="1"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Age</th> <th>Operation</th> </tr> </thead> <tbody> <c:forEach items="${userList}" var="user"> <tr> <td>${user.id}</td> <td>${user.name}</td> <td>${user.age}</td> <td> <a href="${pageContext.request.contextPath}/edit?id=${user.id}">Edit</a> <a href="${pageContext.request.contextPath}/delete?id=${user.id}">Delete</a> </td> </tr> </c:forEach> </tbody> </table> <a href="${pageContext.request.contextPath}/add">Add User</a> <!-- edit.jsp --> <form method="post" action="${pageContext.request.contextPath}/edit"> <input type="hidden" name="id" value="${user.id}"> <label>Name:</label> <input type="text" name="name" value="${user.name}"><br> <label>Age:</label> <input type="text" name="age" value="${user.age}"><br> <input type="submit" value="Submit"> </form> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值