一,创建表

二.将jar包复制导入到lib文件夹下

三.创建工具包连接数据库

package com.bill.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/test?useSSL=false";
public static String db_user = "root";//账号
public static String db_pass = "mm123456";//密码 public static Connection getConn () {
Connection conn = null; try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(db_url, db_user, db_pass);
} catch (Exception e) {
e.printStackTrace();
} return 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();
}
}
} }

四.初始化成员函数

package com.bill.been;

public class Bill {
private int id;
private String type;
private String year;
private String month;
private String day;
private String income;
private String pay;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
public String getIncome() {
return income;
}
public void setIncome(String income) {
this.income = income;
}
public String getPay() {
return pay;
}
public void setPay(String pay) {
this.pay = pay;
} public Bill(int id,String type,String year,String month,String day,String income,String pay)
{
this.id=id;
this.type=type;
this.year=year;
this.month=month;
this.day=day;
this.income=income;
this.pay=pay;
}
public Bill(String type,String year,String month,String day,String income,String pay)
{
this.type=type;
this.year=year;
this.month=month;
this.day=day;
this.income=income;
this.pay=pay;
}
}

五.查找数据库 dao层

package com.bill.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.bill.util.DBUtil;
import com.bill.been.Bill;
@SuppressWarnings("unused")
public class BillDao {
//-----------------------------------------------------------------------------------------------------------------------------
public boolean add(Bill bill) {
String sql = "insert into bill(type,year,month,day,income,pay) values('" + bill.getType() + "','" + bill.getYear() + "','"+bill.getMonth()+"','"+bill.getDay()+"','"+bill.getIncome()+"','"+bill.getPay()+"')";
Connection conn = DBUtil.getConn();//调用方法连接数据库
Statement state = null;
boolean f = false;
int a = 0 ; try { //监视大括号内的代码
state = conn.createStatement();
a = state.executeUpdate(sql);
} catch (Exception e) { //捕获错误
e.printStackTrace();
} finally {
//关闭z 连接
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} //---------------------------------------------------------------------------------------------------------------------------- public Bill getBillById(int id) {
String sql = "select * from bill where id ='" + id + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
Bill bill = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
String type = rs.getString("type");
String year = rs.getString("year");
String month = rs.getString("month");
String day = rs.getString("day");
String income = rs.getString("income");
String pay = rs.getString("pay");
bill = new Bill(id, type, year, month,day,income,pay);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return bill;
} public List<Bill> dellist() {
String sql = "select * from bill";
List<Bill> dellist = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
Bill bean = null;
while (rs.next()) {
int id = rs.getInt("id");
String type2 = rs.getString("type");
String year2 = rs.getString("year");
String month2 = rs.getString("month");
String day2 = rs.getString("day");
String income2=rs.getString("income");
String pay2=rs.getString("pay");
bean = new Bill(id, type2, year2, month2,day2,income2,pay2);
dellist.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return dellist;
} public boolean delete (int id) {
boolean f = false;
String sql = "delete from bill where id='" + id + "'";
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 List<Bill> modifylist() {
String sql = "select * from bill";
List<Bill> modifylist = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
Bill bean = null;
while (rs.next()) {
int id = rs.getInt("id");
String type2 = rs.getString("type");
String year2 = rs.getString("year");
String month2 = rs.getString("month");
String day2 = rs.getString("day");
String income2=rs.getString("income");
String pay2=rs.getString("pay");
bean = new Bill(id, type2, year2, month2,day2,income2,pay2);
modifylist.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return modifylist;
} public boolean modify(Bill bill) {
String sql = "update bill set type='" + bill.getType() + "', year='" + bill.getYear() + "',month='" + bill.getMonth()
+ "',day='"+bill.getDay()+"',income='"+bill.getIncome()+"',pay='"+bill.getPay()+"'where id='" + bill.getId() + "'";
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 List<Bill> search(String type,String year,String month,String day,String income,String pay) {
String sql = "select * from bill where ";
if (type != "") {
sql += "type like '%" + type + "%'";
}
if (year != "") {
sql += "year like '%" + year + "%'";
}
if (month != "") {
sql += "month like '%" + month + "%'";
}
if (day != "") {
sql += "day like '%" + day + "%'";
}if (income != "") {
sql += "income like '%" + income + "%'";
}if (pay != "") {
sql += "pay like '%" + pay + "%'";
}
List<Bill> list = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null; try {
state = conn.createStatement();
rs = state.executeQuery(sql);
Bill bean = null;
while (rs.next()) {
int id = rs.getInt("id");
String type2 = rs.getString("type");
String year2 = rs.getString("year");
String month2 = rs.getString("month");
String day2 = rs.getString("day");
String income2 = rs.getString("income");
String pay2 = rs.getString("pay");
bean = new Bill(id, type2, year2, month2,day2,income2,pay2);
list.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return list;
} }

.六.页面的交互

package com.bill.servlet;
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.bill.dao.BillDao;
import com.bill.been.Bill;
@WebServlet("/BillServlet")
public class BillServlet extends HttpServlet{
private static final long serialVersionUID = 1L; public BillServlet() {
super();
}
BillDao dao=new BillDao(); 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 ("getbillbyid".equals(method)) {
getBillById(req, resp);
}else if ("dellist".equals(method)) {
dellist(req,resp);
}else if ("delete".equals(method)) {
delete(req,resp);
}else if ("getbillbyid2".equals(method)) {
getBillById2(req, resp);
}else if ("modifylist".equals(method)) {
modifylist(req,resp);
}else if ("modify".equals(method)) {
modify(req,resp);
}else if ("search".equals(method)) {
search(req,resp);
}
}
//------------------------------------------------------------------------------------------------------
private void add(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
// TODO Auto-generated method stub
String type = req.getParameter("type");
String year = req.getParameter("year");
String month = req.getParameter("month");
String day = req.getParameter("day");
String income = req.getParameter("income");
String pay = req.getParameter("pay"); Bill bill=new Bill(type,year,month,day,income,pay);
if(dao.add(bill)) {
req.setAttribute("message", "保存成功!");
req.getRequestDispatcher("add.jsp").forward(req, resp);
}else {
req.setAttribute("message", "保存失败!");
req.getRequestDispatcher("add.jsp").forward(req, resp);
}
}
//------------------------------------------------------------------------------------------------------ private void getBillById(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
Bill bill = dao.getBillById(id);
req.setAttribute("bill", bill);
req.getRequestDispatcher("delete.jsp").forward(req,resp); } private void dellist(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
req.setCharacterEncoding("utf-8");
List<Bill> bills = dao.dellist();
req.setAttribute("bills", bills);
req.getRequestDispatcher("dellist.jsp").forward(req,resp); } private void delete(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
dao.delete(id);
req.setAttribute("message", "删除成功");
req.getRequestDispatcher("index.jsp").forward(req,resp);
}
//---------------------------------------------------------------------------------------------------------------------------------
private void getBillById2(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
Bill bill = dao.getBillById(id);
req.setAttribute("bill", bill);
req.getRequestDispatcher("modify.jsp").forward(req,resp); } private void modifylist(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
List<Bill> bills = dao.modifylist();
req.setAttribute("bills",bills);
req.getRequestDispatcher("modifylist.jsp").forward(req,resp);
} private void modify(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
int id = Integer.parseInt(req.getParameter("id"));
String type = req.getParameter("type");
String year = req.getParameter("year");
String month = req.getParameter("month");
String day = req.getParameter("day");
String income = req.getParameter("income");
String pay = req.getParameter("pay");
Bill bill = new Bill(id, type, year, month,day,income,pay); dao.modify(bill);
req.setAttribute("message", "修改成功");
req.getRequestDispatcher("BillServlet?method=modifylist").forward(req,resp);
} //--------------------------------------------------------------------------------------------------------------------------------- private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
String type = req.getParameter("type");
String year = req.getParameter("year");
String month = req.getParameter("month");
String day = req.getParameter("day");
String income = req.getParameter("income");
String pay = req.getParameter("pay");
List<Bill> bills = dao.search(type,year,month,day,income,pay);
req.setAttribute("bills", bills);
req.getRequestDispatcher("searchlist.jsp").forward(req,resp);
}
}

主页面

<%@ 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:bluegreen;">记帐本</h1>
<div class="a">
<a href="add.jsp">账单记录</a>
</div>
<div class="a">
<a href="BillServlet?method=dellist">账单删除</a>
</div>
<div class="a">
<a href="BillServlet?method=modifylist">修改账单</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"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>记录账单</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> <form action="BillServlet?method=add" method="post" onsubmit="return check()">
<div class="a">
类型<input type="text" id="type" name="type"/>
</div>
<div class="a">
年<input type="text" id="year" name="year" />
</div>
<div class="a">
月<input type="text" id="month" name="month"/>
</div>
<div class="a">
日<input type="text" id="day" name="day"/>
</div>
<div class="a">
收入<input type="text" id="income" name="income"/>
</div>
<div class="a">
支出<input type="text" id="pay" name="pay"/>
</div> <div class="a">
<button type="submit" class="b">保&nbsp;&nbsp;&nbsp;存</button>
</div>
<div class="a">
<a href="index.jsp" >返回</a>
</div>
</form>
</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>
<table class="tb">
<tr>
<td>id</td>
<td>账单类型</td>
<td>年</td>
<td>月</td>
<td>日</td>
<td>收入</td>
<td>支出</td>
<td align="center" colspan="2">操作</td>
</tr>
<c:forEach items="${bills}" var="xm">
<tr>
<td>${xm.id}</td>
<td>${xm.type}</td>
<td>${xm.year}</td>
<td>${xm.month}</td>
<td>${xm.day}</td>
<td>${xm.income}</td>
<td>${xm.pay}</td>
<td><a href="BillServlet?method=getbillbyid&id=${xm.id}">删除</a></td>
</tr>
</c:forEach>
</table>
</div>
</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>
<%
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>
<table class="tb">
<tr>
<td>账单类型</td>
<td>${bill.type}</td>
</tr>
<tr>
<td>年</td>
<td>${bill.year}</td>
</tr>
<tr>
<td>月</td>
<td>${bill.month}</td>
</tr>
<tr>
<td>日</td>
<td>${bill.day}</td>
</tr>
<tr>
<td>收入</td>
<td>${bill.income}</td>
</tr>
<tr>
<td>支出</td>
<td>${bill.pay}</td>
</tr>
</table>
<div class="a">
<a onclick="return check()" href="BillServlet?method=delete&id=${bill.id}">删&nbsp;&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"%>
<%@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>
<table class="tb">
<tr>
<td>id</td>
<td>账单类型</td>
<td>年</td>
<td>月</td>
<td>日</td>
<td>收入</td>
<td>支出</td>
<td align="center" colspan="2">操作</td>
</tr>
<c:forEach items="${bills}" var="item">
<tr>
<td>${item.id}</td>
<td>${item.type}</td>
<td>${item.year}</td>
<td>${item.month}</td>
<td>${item.day}</td>
<td>${item.income}</td>
<td>${item.pay}</td>
<td><a href="BillServlet?method=getbillbyid2&id=${item.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</div>
</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: cyan;">记账信息修改</h1>
<a href="index.jsp">返回主页</a>
<form action="BillServlet?method=modify" method="post" onsubmit="return check()">
<div class="a">
账单类型<input type="text" id="type" name="type" value="${bill.type}"/>
</div>
<div class="a">
年<input type="text" id="year" name="year" value="${bill.year}"/>
</div>
<div class="a">
月<input type="text" id="month" name="month" value="${bill.month}"/>
</div>
<div class="a">
日<input type="text" id="day" name="day" value="${bill.day}"/>
</div>
<div class="a">
收入<input type="text" id="income" name="income" value="${bill.income}"/>
</div>
<div class="a">
支出<input type="text" id="pay" name="pay" value="${bill.pay}"/>
</div> <input type="hidden" id="id" name="id" value="${bill.id}"/>
<div class="a">
<button type="submit" class="b">修&nbsp;&nbsp;&nbsp;改</button>
</div>
</form>
</div> </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>
<div align="center">
<h1 style="color: cyan;">账单信息查询</h1>
<a href="index.jsp">返回主页</a>
<form action="BillServlet?method=search" method="post" onsubmit="return check()">
<div class="a">
账单类型<input type="text" id="type" name="type"/>
</div>
<div class="a">
年<input type="text" id="year" name="year" />
</div>
<div class="a">
月<input type="text" id="month" name="month" />
</div>
<div class="a">
日<input type="text" id="day" name="day" />
</div>
<div class="a">
收入<input type="text" id="income" name="income" />
</div>
<div class="a">
支出<input type="text" id="pay" name="pay" />
</div>
<div class="a">
<button type="submit" class="b">查&nbsp;&nbsp;&nbsp;&nbsp;询</button>
</div>
</form>
</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>
<div align="center">
<h1 style="color: red;">账单信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>粘单类型</td>
<td>年</td>
<td>月</td>
<td>日</td>
<td>收入</td>
<td>支出</td>
</tr>
<!-- forEach遍历出adminBeans -->
<c:forEach items="${bills}" var="item" varStatus="status">
<tr>
<td>${item.id}</td>
<td><a>${item.type}</a></td>
<td>${item.year}</td>
<td>${item.month}</td>
<td>${item.day}</td>
<td>${item.income}</td>
<td>${item.pay}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>

jsp连接数据库增删改查的更多相关文章

  1. JavaWeb后端jsp之增删改查

    今日主题:JavaWeb后端jsp之增删改查 实体类: Student.java: package cn.itcast.model.entity; public class Student { pri ...

  2. eclipce连接数据库增删改查

    1.在mysql中新建一个名为course的数据库,并在其中新建一个course数据表,包含四个字段,id,name,teacher,classname如图(注意:将id设为自动递增,否则后面新增会出 ...

  3. php连接数据库增删改查----多条件查询

    关于查询,可以直接写在主页面上 来进行查询 首先,先建立一个表单 <form method="post" action="crud.php"> &l ...

  4. java连接数据库增删改查公共方法

    package dao; import java.io.IOException; import java.sql.CallableStatement; import java.sql.Connecti ...

  5. C#连接数据库 增删改查

  6. java+jsp+sqlserver实现简单的增删改查操作 连接数据库代码

    1,网站系统开发需要掌握的技术 (1)网页设计语言,html语言css语言等 (2)Java语言 (3)数据库 (4)等 2,源程序代码 (1) 连接数据库代码 package com.jaovo.m ...

  7. 数据库中的记录通过servlet回显到jsp页面中(连接数据库或者查询參照:对数据进行增删改查)

    我们常常会用到通过图书的名称来查询图书那么这种话我们也就会使用到从数据库中搜索出数据而且载入到自己的Jsp页面中 这种话我们须要将从数据库中获取到的数据放进响应中然后通过%=request.getAt ...

  8. 最简单的jsp+servlet的增删改查代码

    package ceet.ac.cn.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.s ...

  9. web项目总结——通过jsp+servlet实现对oracle的增删改查功能

    1.DAO模式 分包:依次建立 entity:实体包,放的是跟oracle数据库中表结构相对应的对象的属性,也就是这个对象有什么 dao:增删改查接口,实现增删改查的具体方法 service:同dao ...

随机推荐

  1. HTML单词

    html超文本标记语言 head 头部font 字体 字形i(italic) 倾斜,斜体字big 大的,字体加大hr 水平线Pre(predefined)预定义h5标题5Div(division)区隔 ...

  2. 关键字Lock的简单小例子

    一.什么是Lock? Lock——字面上理解就是锁上:锁住:把……锁起来的意思: 为什么要锁?要锁干什么?——回到现实中可想象到,这个卫生间我要上,其他人不要进来!(所以我要锁住门):又或者土味情话所 ...

  3. 为spring cloud config实现刷新动态掉的坑

    正常搭建配置中心,网上教程多,这里不讨论,只记坑也是为了后来者少花时间在这里,由于是当时研究了好久才写的文章,所以只能提供问题的原因,当然会给出印证的思路,闲话不多说进入正题! 版本spring bo ...

  4. Python3标准库:heapq堆排序算法

    1. heapq堆排序算法 堆(heap)是一个树形数据结构,其中子节点与父节点有一种有序关系.二叉堆(binary heap)可以使用一个有组织的列表或数组表示,其中元素N的子元素位于2*N+1和2 ...

  5. Electron – 项目报错整理(打包~2): electron-packager踩坑

  6. 战“疫”背后的AI身影丨曼孚科技

    近期新型冠状病毒肺炎的疫情,牵动着全国上下人民的心. 截止2月11日上午10点,全国确诊人数已达42708人,疑似病例21675人. 突发的疫情让部分地区的快速诊疗能力出现了结构性的缺失,为了打赢这场 ...

  7. STL入门学习中碰到的一些函数

    2020.02.10 fill #include<algorithm> vector<int> v{ 1, 2, 3, 3 }; fill(v.begin(), v.end() ...

  8. C# WPF 时钟动画(1/2)

    微信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏. C# WPF 时钟动画(1/2) 内容目录 实现效果 业务场景 编码实现 本文参考 源码下载 ...

  9. web端常见测试

    一.登录注册功能 1.页面调转 2.tab键与enter键 3.密码加密显示,是否支持复制粘贴 4.账号密码校验 5.刷新页面,更新验证码 二.界面测试 1.样式.颜色.整体布局风格 2.最大化.最小 ...

  10. vue router的嵌套使用与传值的query方式

    嵌套路由 当我们不满足与 /home这种路由,而是希望通过 /home/news和/home/message访问一些内内容 那么就需要嵌套路由了 实现嵌套路由有两个步骤: ·创建对应的子组件,并且在路 ...