本系统采用JAVAEE开发形式,利用数据库来完成数据存储功能,运用了B/S形式的开发模式,严格按照了软件工程的开发模式进行开发,保证系统的良好运行。
关键词:停车场系统;Javaee;Tomcat
package com.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.DB;
/**
-
Servlet implementation class Cw_deleteServlet
*/
public class Cw_deleteServlet extends HttpServlet {
private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取id
int id = Integer.valueOf(request.getParameter(“id”));
try {
DB hy = new DB();
Connection str = hy.getCon();
// 删除信息的SQL语句
String sqltt = “delete from chewei where id=?”;
// 获取PreparedStatement
PreparedStatement pstt = str.prepareStatement(sqltt);
// 对SQL语句中的第一个占位符赋值
pstt.setInt(1, id);
// 执行更新操作
pstt.executeUpdate();
// 关闭PreparedStatement
pstt.close();
// 关闭Connection
str.close();
} catch (Exception e) {
e.printStackTrace();
}
// 重定向到TeachServlet
response.sendRedirect("./admin/chewei_mg.jsp");
}
}
package com.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.DB;
/**
-
Servlet implementation class Hf_Servlet
*/
public class Hf_Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取idString id=new String(request.getParameter("id").getBytes("ISO-8859-1"),"GB18030"); try { DB vvv = new DB(); Connection sty = vvv.getCon(); // 删除信息的SQL语句 String sqlmm = "update weigui set states='' where id=?"; // 获取PreparedStatement PreparedStatement pscc = sty.prepareStatement(sqlmm); // 对SQL语句中的第一个占位符赋值 pscc.setString(1, id); // 执行更新操作 pscc.executeUpdate(); // 关闭PreparedStatement pscc.close(); // 关闭Connection sty.close(); } catch (Exception e) { e.printStackTrace(); } // 重定向到TeachServlet //out.println("<script>alert('更改成功!');window.location.href='info_up.jsp';</script>"); response.sendRedirect("./admin/weigui_huifu.jsp");
}
}
package com.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.DB;
/**
-
Servlet implementation class Wg_delServlet
*/
public class Wg_delServlet extends HttpServlet {
private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 获取id
int id = Integer.valueOf(request.getParameter(“id”));
try {
DB hy = new DB();
Connection str = hy.getCon();
// 删除信息的SQL语句
String sqltt = “delete from weigui where id=?”;
// 获取PreparedStatement
PreparedStatement pstt = str.prepareStatement(sqltt);
// 对SQL语句中的第一个占位符赋值
pstt.setInt(1, id);
// 执行更新操作
pstt.executeUpdate();
// 关闭PreparedStatement
pstt.close();
// 关闭Connection
str.close();
} catch (Exception e) {
e.printStackTrace();
}
// 重定向到TeachServlet
response.sendRedirect("./admin/weigui_mg.jsp");
}
}
下面是数据库
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[chewei]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[chewei](
[id] [int] IDENTITY(1,1) NOT NULL,
[chewei_no] nvarchar NULL,
[chewei_type] nvarchar NULL,
[chewei_state] nvarchar NULL,
[chewei_didian] nvarchar NULL,
CONSTRAINT [PK_chewei] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[reg]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[reg](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] nvarchar NULL,
[password] nvarchar NULL,
[chepaihao] nvarchar NULL,
[jine] nvarchar NULL,
[truename] nvarchar NULL,
[tel] nvarchar NULL,
[jianjie] nvarchar NULL,
[quanxian] nvarchar NULL CONSTRAINT [DF_reg_quanxian] DEFAULT (N’会员’),
[shijian] [datetime] NULL,
CONSTRAINT [PK_reg] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[weigui]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[weigui](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] nvarchar NULL,
[chepaihao] nvarchar NULL,
[states] nvarchar NULL,
[shuoming] nvarchar NULL,
CONSTRAINT [PK_weigui] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[feiyong]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[feiyong](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] nvarchar NULL,
[yonghu_type] nvarchar NULL,
[zhifu_type] nvarchar NULL,
[jine] nvarchar NULL,
[beizhu] nvarchar NULL,
[shijian] [datetime] NULL,
CONSTRAINT [PK_feiyong] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[login]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[login](
[id] [int] IDENTITY(1,1) NOT NULL,
[username] nvarchar NULL,
[password] nvarchar NULL,
CONSTRAINT [PK_login] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[gg]’) AND type in (N’U’))
BEGIN
CREATE TABLE [dbo].[gg](
[id] [int] IDENTITY(1,1) NOT NULL,
[Gg_titile] nvarchar NULL,
[Gg_neirong] nvarchar NULL,
[shijian] [datetime] NULL,
CONSTRAINT [PK_gg] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
运行截图