Java—简单的图书管理系统

简单的图书管理系统
通过数据源和DAO对象访问数据库。其中JavaBeans实现模型,访问数据库,Servlet实现控制器,JSP页面实现视图。
• 模型包括2个JavaBean:BookBean用于存放图书信息,BookDAO用于访问数据库。
• 控制器包括2个Servlet:BookQueryServlet根据请求参数查询图书信息、BookInsertServlet用来向数据库中插入数据。
• 视图包括4个JSP页面:bookQuery.jsp显示查询页面、bookInsert.jsp显示插入页面、display.jsp显示查询结果页面和errorPage.jsp显示错误页面。

context.xml配置

<?xml version="1.0" encoding="UTF-8"?>

<Context>
    <Resource
            auth="Container"
            driverClassName="com.mysql.cj.jdbc.Driver"
            maxIdle="30"
            maxTotal="50"
            maxWaitMillis="-1"
            name="jdbc/book"
            username="rotdas"
            password="dasdash"
            type="javax.sql.DataSource"
            url="jdbc:mysql://127.0.0.1:3306/book?serverTimezone=UTC"/>
</Context>

源代码

BookBean代码
	public class BookBean implements Serializable {
   
    private String bookid = null;
    private String title = null;
    private String author = null;
    private String publisher = null;
    private float price = 0.0F;
    public BookBean(){
   }
    public BookBean(String bookId, String author,
                    String title, String publisher, float price) {
   
        this.bookid = bookId;
        this.title = title;
        this.author = author;
        this.publisher = publisher;
        this.price = price;
    }
    public String getBookid() {
    return this.bookid; }
    public String getTitle() {
    return title; }
    public String getAuthor() {
    return this.author; }
    public float getPrice() {
    return price; }
    public String getPublisher () {
    return publisher; }

    public void setBookid(String bookid){
    this.bookid=bookid; }
    public void setTitle(String title){
   this.title=title; }
    public void setAuthor(String author){
    this. author = author; }
    public void setPrice(float price){
   this.price=price; }
    public void setPublisher (String publisher){
    this
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值