通过一个综合型的例子加深对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`))
写一个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