Home  >  Article  >  Database  >  JDBC操作数据库CRUD综合应用实例

JDBC操作数据库CRUD综合应用实例

WBOY
WBOYOriginal
2016-06-07 17:36:53997browse

通过一个综合型的例子加深对JDBC操作数据库的增、删、改、查的运用。经典的图书信息录入实例设计数据库CREATETABLE`tb_books`(`id`int(10)unsignedNOTNULLAUTO_I

通过一个综合型的例子加深对JDBC操作数据库的增、删、改、查的运用。

经典的图书信息录入实例


设计数据库

CREATE TABLE `tb_books` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, `price` double NOT NULL, `bookCount` int(10) unsigned NOT NULL, `author` varchar(45) NOT NULL, PRIMARY KEY (`id`) )


wKioL1Lc1R6gdL0NAAHwzIdUb9A861.jpg


写一个Book类对图书信息进行封装

package com.lixiyu; public class Book { private int id; private String name; private double price; private int bookCount; private String author; public int getId(){ return id; } public void setId(int id){ this.id=id; } public String getName(){ return name; } public void setName(String name){ this.name=name; } public double getPrice(){ return price; } public void setPrice(double price){ this.price=price; } public int getbookCount(){ return bookCount; } public void setbookCount(int bookCount){ this.bookCount=bookCount; } public String getAuthor(){ return author; } public void setAuthor(String author){ this.author=author; } }




添加(insert)图书信息操作


创建AddBook.jsp页面,用于对添加图书信息进行处理

Insert title here
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn