用java做的一个图书管理系统的源代码word版本

合集下载

(完整word版)图书管理系统源代码

(完整word版)图书管理系统源代码

图书管理系统源代码(一)程序代码1。

主窗口界面import java.awt。

*;import java.awt。

event.*;import javax。

swing.*;import javax.swing.border.TitledBorder;import java.awt。

Font;import javax.swing。

JMenu;public class MainWindow extends JFrame implements ActionListener { private static final long serialVersionUID = 1L;static String loginName;static String loginNo;JLabel mlabel;JPanel jp=new JPanel();//建立菜单栏JMenu a=new JMenu();JMenu b=new JMenu();JMenu c=new JMenu();//建立系统管理菜单组JMenuItem aa=new JMenuItem();JMenuItem ab=new JMenuItem();JMenuItem ac=new JMenuItem();//建立读者管理菜单组JMenuItem bb=new JMenuItem();//建立书籍管理菜单组JMenuItem ca=new JMenuItem();JMenuItem cb=new JMenuItem();JMenuItem cc=new JMenuItem();JMenuItem cd=new JMenuItem();public MainWindow(){super(”图书管理系统");addWindowListener(new WindowAdapter(){System.exit(0);}});Container d=getContentPane();this。

用java做的一个图书管理系统的源代码

用java做的一个图书管理系统的源代码

用java做的一个图书管理系统的源代码import java.sql.*;import java.util.*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner(System.in);System.out.println("请输入用户名:");String username2=scanner.next();System.out.println("请输入密码:");String password2=scanner.next();if(!(username2.equals("")||password2.equals(""))){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn=DriverManager.getConnection("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=conn.createStatement();rs=stmt.executeQuery(sql);if(rs.next()){if(rs.getString("password").equals(password2)){System.out.println("*********欢迎来山东科技大学图书馆管理系统********");while(true){System.out.println(" 1.图书信息");System.out.println(" 2.读者信息");System.out.println(" 3.管理员信息");System.out.println(" 4.借阅信息");System.out.println(" 5.还书信息");System.out.println(" 6.逾期罚款或损坏赔偿信息");//System.out.println(" 7.退出");System.out.println(" 请输入选择功能的序号:");int a=scanner.nextInt();switch(a){case 1:System.out.println(" 图书信息: ");System.out.println(" 1. 查询图书信息: ");System.out.println(" 2. 插入图书信息: ");System.out.println(" 3. 删除图书信息: ");System.out.println(" 4. 修改图书信息: ");int a1=scanner.nextInt();switch(a1){case 1:System.out.println(" 欢迎进入图书信息查询系统: ");System.out.println(" 1. 无条件查询图书信息: ");System.out.println(" 2. 条件查询图书信息: ");int d=scanner.nextInt();switch(d){case 1:int llll=0;//int mm=0;while(llll!=1){System.out.println(" 1. 无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql0);while(rs.next()){String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+bookWriter+","+bookPub);}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){llll=1;System.out.println();};}break;//break;case 2:System.out.println(" 2. 条件查询图书信息: ");System.out.println(" 1. 单条件查询图书信息: ");System.out.println(" 2. 模糊条件查询图书信息: ");System.out.println(" 3. 多表连接查询图书信息: ");System.out.println(" 4. 嵌套查询图书信息: ");System.out.println(" 5. 谓词演算查询");int c12=scanner.nextInt();switch(c12){case 1:System.out.println(" 1.单条件查询: ");System.out.println(" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){System.out.println("请输入图书编码号:");String A=scanner.next();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= stmt.executeQuery(sql1);int x=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续按姓名查询?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};};}break;case 2:System.out.println(" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){System.out.println("请用户输入图书名字中的模糊关键字");String E=scanner.next();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= stmt.executeQuery(sq123);int z=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){dc=1;System.out.println();// break;};}}break;case 3:System.out.println(" 3.多表连接查询查询图书信息: ");int dq=0;while(dq!=1){System.out.println("查询逾期罚款或是赔偿表中的读者的相关信息");System.out.println("请输入逾期罚款或是赔偿的读者编码号");String F=scanner.next();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE fine.bookID=borrowbook.bookID AND borrowbook.reaID=systemreader.reaID AND fine.bookID='"+F+"' ";rs= stmt.executeQuery(sq1234);int n=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};}}break;case 4:System.out.println(" 4.嵌套查询图书信息: ");int dq1=0;while(dq1!=1){System.out.println("查询某读者所在年级女读者的相关信息");System.out.println("请输入某读者的读者编号");String G=scanner.next();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= stmt.executeQuery(sq12345);int m=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入读者编号?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;case 5:System.out.println(" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){System.out.println("查询借阅了某本书的读者的相关信息");System.out.println("请输入该书的名字");String H=scanner.next();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= stmt.executeQuery(sq123456);int l=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字?yes/no no 返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;}//c12break;}break;/*case 1:System.out.println(" 1. 查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql);while(rs.next()){//String str =scanner.next();String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}break;*/case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书信息: ");System.out.println("请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;//int mm=0;while(ll!=1){System.out.println(" 3. 删除图书信息: ");System.out.println("请输入要删除的图书编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}b reak;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改图书信息: ");System.out.println("请输入修改的图书ID ");String S=scanner.next();String sql1="SELECT * FROM systembook where bookID='"+S+"'"; rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这本书,请重新输入");}else{System.out.println("要将书名改为");String bbb=scanner.next();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql1); //返回记录影响的条数if(hh!=0){S ystem.out.println("修改成功!");}S ystem.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/* String updateSql="UPDATE systembook SET bookCopy='"+c1+"' WHERE bookName='数据库管理'";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){S ystem.out.println("修改成功!");}b reak;}break;*/case 2:System.out.println(" 读者信息: ");System.out.println(" 1. 查询读者信息: ");System.out.println(" 2. 插入读者信息: ");System.out.println(" 3. 删除读者信息: ");System.out.println(" 4. 修改读者信息: " );int b1=scanner.nextInt();switch(b1){case 1:System.out.println(" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= stmt.executeQuery(ssql);while(rs.next()){// String str =scanner.next();String reaID=rs.getString(1);String reaName =rs.getString(2);String reaLBID =rs.getString(3);String reaNo =rs.getString(4);String reaSex =rs.getString(5);String reaType =rs.getString(6);String reaDep =rs.getString(7);String reaGrade =rs.getString(8);String reaPre =rs.getString(9);String reaDate =rs.getString(10);System.out.println(reaID+","+reaName+","+reaNo+","+reaSex+","+reaLBID+","+reaType+","+rea Dep+","+reaGrade+","+reaPre+","+reaDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入读者信息: ");System.out.println("请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=scanner.next();String []splitst=str.split(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTO systemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"',' "+b20+"')";int n=stmt.executeUpdate(insertSql); //返回记录影响的条数if(n!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除读者信息: "); System.out.println("请输入要删除的读者证号:");String Str=scanner.next();String []Splitst=Str.split(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);String g22 =rs.getString(7);String h22 =rs.getString(8);String i22 =rs.getString(9);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){System.out.println( "没有这个读者,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int m=stmt.executeUpdate(deleSql); //返回记录影响的条数if(m!=0){System.out.println("删除成功!");}*/break;c ase 4:i nt mm=0;while(mm!=1){System.out.println(" 4. 修改读者信息: "); System.out.println("请输入修改以后的读者的ID ");String S=scanner.next();// String []Ssplitst=S.split(",");//String tt=Ssplitst[0];String sql1="SELECT * FROM systemreader where reaID='"+S+"'"; rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);String g222 =rs.getString(7);String h222 =rs.getString(8);String i222 =rs.getString(9);String j222 =rs.getString(10);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222+","+g222+","+h22 2+","+i222+","+j222);lll++;}if(lll==0){System.out.println( "没有这个人,请重新输入");}else{System.out.println("要将名字改为");String bb=scanner.next();String updateSql="UPDATE systemreader SET reaName='"+bb+"' WHERE reaID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){S ystem.out.println("修改成功!");}S ystem.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;/* String updateSql="UPDATE systemreader SET reaSex='"+tt+"' WHERE reaID='20030101'";int l=stmt.executeUpdate(updateSql); //返回记录影响的条数if(l!=0){S ystem.out.println("修改成功!");}b reak;*/}break;case 3:System.out.println(" 管理员信息: "); System.out.println(" 1. 查询管理员信息: "); System.out.println(" 2. 插入管理员信息: "); System.out.println(" 3. 删除管理员信息: "); System.out.println(" 4. 修改管理员信息: "); System.out.println(" 5. 返回上一级");int c11=scanner.nextInt();switch(c11){case 1:System.out.println(" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= stmt.executeQuery(Ssql);while(rs.next()){// String str =scanner.next();String mID =rs.getString(1);String mName=rs.getString(2);String mSex =rs.getString(3);System.out.println(mID+","+mName+","+mSex);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入管理员信息: ");System.out.println("请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTO manager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除管理员信息: ");System.out.println("请输入要删除的管理员编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这个管理员,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM manager WHERE mID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE mID FROM manager WHERE mID='"+b3+"'"; int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改管理员信息: ");System.out.println("请输入要修改的管理员编号:");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这个管理员,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将它改为");String bb=scanner.next();String updateSql="UPDATE manager SET mName='"+bb+"' WHERE mID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){S ystem.out.println("修改成功!");}S ystem.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/*String updateSql="UPDATE manager SET mSex='"+c1+"' WHERE mID=1"; int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}}break;*/case 4:System.out.println(" 图书借阅信息: ");System.out.println(" 1. 查询图书借阅信息信息: ");System.out.println(" 2. 插入图书借阅信息: ");System.out.println(" 3. 删除图书借阅信息: ");System.out.println(" 4. 修改图书借阅信息: ");System.out.println(" 5. 返回上一级");int d=scanner.nextInt();switch(d){case 1:System.out.println(" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= stmt.executeQuery(Sql4);while(rs.next()){String bookID =rs.getString(1);String reaID =rs.getString(2);String outDate =rs.getString(3);String yhDate =rs.getString(4);System.out.println(bookID+","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书借阅信息: ");System.out.println("请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];//String a15=splitst[4];//String a16=splitst[5];String insertSql="INSERT INTO borrowbook(bookID,reaID,outDate,yhDate) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"')";int ii=stmt.executeUpdate(insertSql); //返回记录影响的条数if(ii!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除图书借阅信息: ");System.out.println("请输入要删除的图书条码号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);// String e22 =rs.getString(5);//String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM borrowbook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};}}}/* String deleSql= "DELETE bookID FROM borrowbook WHERE bookID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1)System.out.println(" 4. 修改借阅读书信息: ");System.out.println("请输入要修改的图书的ID ");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);//String e222 =rs.getString(5);//String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222);lll++;}if(lll==0){System.out.println( "没有这条记录,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将借阅日期改为");String bb=scanner.next();String updateSql="UPDATE borrowbook SET outDate='"+bb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){S ystem.out.println("修改成功!");}S ystem.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();。

原创java图书借阅管理系统全部源代码

原创java图书借阅管理系统全部源代码

原创Java图书借阅管理系统全部源代码1. 介绍本文档提供了一个原创的Java图书借阅管理系统的全部源代码。

该系统可以帮助图书馆或其他类似机构管理他们的图书借阅流程。

系统包括了一系列功能,包括添加图书、借阅图书、归还图书、查询图书等。

2. 功能概述•添加图书:管理员可以通过系统添加新的图书信息,包括书名、作者、出版社等。

•借阅图书:读者可以通过系统进行图书借阅。

系统会检查图书是否可用,并更新图书的状态和借阅记录。

•归还图书:读者可以通过系统归还已借阅的图书。

系统会更新图书的状态和借阅记录。

•查询图书:管理员和读者可以通过系统查询图书的信息,包括图书的借阅情况和在馆数量等。

3. 系统架构该系统采用Java语言开发,使用MVC(Model-View-Controller)架构模式。

MVC模式将应用程序分为三个核心组件:•模型(Model):负责处理数据相关的操作,如数据库的读写、数据的验证和处理等。

•视图(View):负责展示用户界面,根据模型的数据渲染出相应的界面。

•控制器(Controller):负责接收用户的输入,调用相应的模型和视图,处理用户请求并返回相应的结果。

4. 源代码结构本系统的源代码包含以下几个主要的文件和文件夹:•Book.java:定义图书类,包含图书的属性和方法。

•User.java:定义用户类,包含用户的属性和方法。

•Database.java:封装数据库的操作,包括连接数据库、读取数据和写入数据等。

•BookController.java:图书控制器,负责处理图书相关的逻辑。

•UserController.java:用户控制器,负责处理用户相关的逻辑。

•View.java:视图类,负责展示用户界面和接收用户输入。

•Main.java:程序入口,初始化系统并启动。

5. 使用方法1.下载源代码并解压缩到本地计算机。

2.使用Java开发工具打开项目。

3.编译并运行Main.java文件。

用Java写一个图书管理系统的代码

用Java写一个图书管理系统的代码

用Java写一个图书管理系统的代码```import java.util.*;public class BookManager {// Create a list for book storageprivate List<Book> books;public BookManager() {books = new ArrayList<Book>();}// Add a book to the listpublic void addBook(Book book) {books.add(book);}// Remove a book from the listpublic void removeBook(Book book) {books.remove(book);}// Get all books in the listpublic List<Book> getAllBooks() {return books;}// Search a book by book namepublic List<Book> searchByName(String name) {List<Book> resultBooks = new ArrayList<Book>();for (Book book : books) {if (book.getName().equals(name)) {resultBooks.add(book);}}return resultBooks;}// Search a book by author namepublic List<Book> searchByAuthor(String author) { List<Book> resultBooks = new ArrayList<Book>(); for (Book book : books) {if (book.getAuthor().equals(author)) {resultBooks.add(book);}}return resultBooks;}}class Book {private String name;private String author;public Book(String name, String author) { = name;this.author = author;}public String getName() {return name;}public void setName(String name) { = name;}public String getAuthor() {return author;}public void setAuthor(String author) { this.author = author;}}```。

java项目开发实例图书信息管理系统开发文档及源码.doc

java项目开发实例图书信息管理系统开发文档及源码.doc

java项目开发实例图书信息管理系统开发文档及源码.doc
预览说明:预览图片所展示的格式为文档的源格式展示,下载源文件没有水印,内容可编辑和复制
图书信息管理系统
一、系统功能概述:
根据图书信息管理系统的特点,可以将本系统分为2大功能模块,分别为:基础数据维护、系统数据维护。

本系统各个部分及其包括的具体功能模块如下图所示:
二、数据库设计:
图书信息表:
字段名说明类型长度及备注
ISBN 国际标准书号Varchar(13) 主键
typeId 图书类型id Int
Bookname 书名Varchar(40)
Writer 作者Varchar(21)
Translater 译者Varchar(30) 可以为空Publisher 出版社Varchar(50)
Date 出版日期Smalldatetime
Price 价格money
图书类别表:
用户信息表:
三、系统源代码:
Com.zhang.dao:Dao.java //数据库的连接与操作类package com.zhang.dao;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.SQLException;。

基于java的图书管理系统源代码【范本模板】

基于java的图书管理系统源代码【范本模板】

声明:本系统是基于C/S的图书管理系统,主要使用的是Oracle数据库,下面附所有实现代码package library;import java.awt。

BorderLayout;import java.awt。

Container;import java。

awt。

GridLayout;import java。

awt.event.ActionEvent;import java。

awt。

event。

ActionListener;import java。

sql.ResultSet;import javax。

swing.JButton;import javax.swing。

JComboBox;import javax.swing.JFrame;import javax.swing。

JLabel;import javax。

swing。

JOptionPane;import javax。

swing。

JPanel;import javax.swing.JTextField;public class book_add extends JFrame implements ActionListener{DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2;JLabel book_id_label,book_name_label,author_label,press_label,press_date_label,price_label,book_num_label,borrowed_num_label,address;JTextField book_id_TextField,book_name_TextField,author_TextField,press_TextField,press_date_TextField,price_TextField,book_num_TextField, borrowed_count;JComboBox addresst;Container c;JButton clear,add,exit;public book_add(){super(”添加图书信息");c=getContentPane();c。

图书管理系统源码(java实现)

图书管理系统源码(java实现)

【图书管理系统】【MainPro包】1.系统登录页面public class Login extends Frame {private static final long serialVersionUID = -1758475247807861408L;TextField text_user;TextField text_pass;public Login() {1 this.setTitle("登录");this.setLayout(null);//默认流式布局this.setSize(260, 170);/* 定义标签与文本框*/Label lbUser = new Label("用户名:");text_user = new TextField();Label lbPass = new Label("密码:");text_pass = new TextField();Button btn_ok = new Button("确定");Button btn_cancel = new Button("取消");lbUser.setBounds(40, 53, 60, 20);//x,y,width,heightlbPass.setBounds(40, 83, 60, 20);text_user.setBounds(100, 50, 120, 20);text_pass.setBounds(100, 80, 120, 20);btn_ok.setBounds(45, 120, 80, 25); // 确定按钮btn_cancel.setBounds(135, 120, 80, 25); // 取消按钮/* 添加标签与文本框*/add(lbUser);add(lbPass);add(text_user);add(text_pass);add(btn_ok);add(btn_cancel);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置this.setVisible(true); // 使窗体可见btn_ok.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {btn_okActionPerformed(e);//自定义确定按钮触发的实施过程}}));btn_cancel.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}}));this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);} }); }public void btn_okActionPerformed(ActionEvent e) {String user = text_user.getText();String pass = text_pass.getText();String is_admin;// 如果用户名或密码任一为空,则终止后续操作if (user.equals("")||pass.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");return;}try {// 核对用户名和密码String sql = "select * from user where username=" + "'" + user + "' and password=" + "'" + pass + "'";ResultSet rs = DbOp.executeQuery(sql);// 如果此用户存在,则记录其状态(否:不是管理员,是:是管理员)if (rs.next()) {is_admin = rs.getString("is_admin");} else {JOptionPane.showMessageDialog(null, "用户名或密码不正确!");return;}GlobalVar.login_user = user; // 记录登录的用户名ShowMain show = new ShowMain(); // 调用主程序// 只有管理员才能使用"基础管理"和"借阅管理"菜单show.setRights(is_admin);// 释放窗体及其全部组件的屏幕资源,即使释放登录窗体dispose(); // 释放当前窗体} catch (SQLException e1) {JOptionPane.showMessageDialog(null, "用户数据库有误!");}}}2.系统首页页面public class ShowMain extends Frame {private static final long serialVersionUID = 5003296786441785470L;MenuBar menuBar;Menu jcwh, jcwh_book, jcwh_reader;//基础维护:图书维护、读者维护Menu jywh, cxgl, xtgl;//借阅维护、查询管理、系统管理MenuItemjcwh_book_add,jcwh_book_update,jcwh_book_delete,jcwh_reader_add,jcwh_reader_update,jcwh_reader_delete;MenuItem jywh_borrow, jywh_back;MenuItem cxgl_book, cxgl_reader;MenuItem xtgl_update_pass, xtgl_exit;public void setRights(String rights) {// 如果不是管理员,则禁止用户维护图书信息和读者信息以及禁止进行借阅管理,即只能查询if (rights.equals("否")) {jywh.setEnabled(false);jcwh.setEnabled(false);}}public ShowMain() {setTitle("图书管理系统");setLayout(new BorderLayout());setSize(640, 480);menuBar = new MenuBar();jcwh = new Menu("基础维护");// 基础维护菜单jcwh_book = new Menu("图书维护");// 图书维护菜单jcwh_book_add = new MenuItem("添加");// 添加图书菜单jcwh_book_update = new MenuItem("修改");// 修改图书菜单jcwh_book_delete = new MenuItem("删除");// 删除图书菜单jcwh_reader = new Menu("读者维护");// 读者维护菜单jcwh_reader_add = new MenuItem("添加读者");// 添加读者菜单jcwh_reader_update = new MenuItem("修改读者");jcwh_reader_delete = new MenuItem("删除读者");jywh = new Menu("借阅管理");jywh_borrow = new MenuItem("借书管理");jywh_back = new MenuItem("还书管理");cxgl = new Menu("查询管理");cxgl_book = new MenuItem("图书查询");cxgl_reader = new MenuItem("读者查询");xtgl = new Menu("系统管理");xtgl_update_pass = new MenuItem("修改密码");xtgl_exit = new MenuItem("退出系统");// 添加图书菜单jcwh_book.add(jcwh_book_add);jcwh_book.add(jcwh_book_update);jcwh_book.add(jcwh_book_delete);jcwh.add(jcwh_book);jcwh_reader.add(jcwh_reader_add);jcwh_reader.add(jcwh_reader_update);jcwh_reader.add(jcwh_reader_delete);jcwh.add(jcwh_reader);jywh.add(jywh_borrow);jywh.add(jywh_back);cxgl.add(cxgl_book);cxgl.add(cxgl_reader);xtgl.add(xtgl_update_pass);xtgl.add(xtgl_exit);menuBar.add(jcwh);menuBar.add(jywh);menuBar.add(cxgl);menuBar.add(xtgl);setMenuBar(menuBar);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见jcwh_book_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("save");} });jcwh_book_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("update");} });jcwh_book_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("delete");} });jcwh_reader_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("save");} });jcwh_reader_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("update");} });jcwh_reader_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("delete");} });jywh_borrow.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Borrow();} });jywh_back.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Back();} });cxgl_book.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookQuery();} });cxgl_reader.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderQuery();} });xtgl_update_pass.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new UpdatePassword();} });xtgl_exit.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});}}3.图书管理public class BookManeger extends JFrame {private static final long serialVersionUID = 377287301994613384L;private Label lbbookid_c = new Label("图书编号");private TextField tf_bookid_c = new TextField();private Label lbbookid = new Label("图书编号");private TextField tf_bookid = new TextField();private Label lbbookname = new Label("图书名称");private TextField tf_bookname = new TextField();private Label lbbooktype = new Label("图书类别");private Choice tf_booktype = new Choice();private Label lbauthor = new Label("作者");private TextField tf_author = new TextField();private Label lbtranslator = new Label("译者");private TextField tf_translator = new TextField();private Label lbpublisher = new Label("出版社");private TextField tf_publisher = new TextField();private Label lbpublish_time = new Label("出版时间");private TextField tf_publish_time = new TextField();private Label lbprice = new Label("定价");private TextField tf_price = new TextField();private Label lbstock = new Label("库存数量");private TextField tf_stock = new TextField();private Button queryBtn = new Button("查询");private Button saveBtn = new Button("保存");private Button closeBtn = new Button("关闭");private String optionStr;BookManeger(String str) {optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid);map.put("bookname", tf_bookname);map.put("booktype", tf_booktype);map.put("author", tf_author);map.put("translator", tf_translator);map.put("publisher", tf_publisher);map.put("publish_time", tf_publish_time);map.put("price", tf_price);map.put("stock", tf_stock);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delActionPerformed(e, map);}else{i = Jcwh.btn_saveActionPerformed(e, map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "图书添加成功!";}else if(optionStr.equals("update")){showInfo = "图书修改成功!";}else if(optionStr.equals("delete")){showInfo = "图书删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});/* 关闭窗口*/this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setSize(500, 320);lbbookid.setBounds(50, 40, 50, 20); // 图书编号tf_bookid.setBounds(110, 40, 100, 20);lbbookname.setBounds(240, 40, 50, 20); // 图书名称tf_bookname.setBounds(300, 40, 100, 20);lbbooktype.setBounds(50, 80, 50, 20); // 图书类别tf_booktype.setBounds(110, 80, 100, 20);tf_booktype.add("科技");tf_booktype.add("文学");tf_booktype.add("社科");tf_booktype.add("其他");lbauthor.setBounds(240, 80, 50, 20); // 作者tf_author.setBounds(300, 80, 100, 20);lbtranslator.setBounds(50, 120, 50, 20); // 设置译者tf_translator.setBounds(110, 120, 100, 20);lbpublisher.setBounds(240, 120, 50, 20); // 出版社tf_publisher.setBounds(300, 120, 100, 20);lbpublish_time.setBounds(50, 160, 50, 20); // 出版时间tf_publish_time.setBounds(110, 160, 100, 20);lbprice.setBounds(240, 160, 50, 20); // 定价tf_price.setBounds(300, 160, 100, 20);lbstock.setBounds(50, 200, 50, 20); // 库存数量tf_stock.setBounds(110, 200, 100, 20);saveBtn.setBounds(150, 240, 80, 25); // 保存按钮closeBtn.setBounds(280, 240, 80, 25);// 关闭按钮if(str.equals("save")){setTitle("添加图书");}else if(str.equals("update")){setTitle("修改图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbbookid);add(tf_bookid);add(lbbookname);add(tf_bookname);add(lbbooktype);add(tf_booktype);add(lbauthor);add(tf_author);add(lbtranslator);add(tf_translator);add(lbpublisher);add(tf_publisher);add(lbpublish_time);add(tf_publish_time);add(lbprice);add(tf_price);add(lbstock);add(tf_stock);add(saveBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见}private void clearAllTextfield() {tf_bookid.setText("");tf_bookname.setText("");tf_author.setText("");tf_translator.setText("");tf_publisher.setText("");tf_publish_time.setText("");tf_price.setText("");tf_stock.setText("");}}4.读者管理public class ReaderManeger extends JFrame {private static final long serialVersionUID = -2399939451497711745L;Label lbreaderid_c = new Label("读者编号");TextField tf_readerid_c = new TextField();Label lbreaderid = new Label("读者编号");TextField tf_readerid = new TextField();Label lbreadername = new Label("读者姓名");TextField tf_readername = new TextField();Label lbreadertype = new Label("读者类别");Choice tf_readertype = new Choice();Label lbsex = new Label("性别");Choice tf_sex = new Choice();Label lbmax_num = new Label("可借数量");TextField tf_max_num = new TextField();Label lbdays_num = new Label("可借天数");TextField tf_days_num = new TextField();Button queryBtn = new Button("查询");Button saveBtn = new Button("保存");Button closeBtn = new Button("关闭");private String optionStr;//保存、修改、删除ReaderManeger(String str){optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid);map.put("readername", tf_readername);map.put("readertype", tf_readertype);map.put("sex", tf_sex);map.put("days_num", tf_days_num);map.put("max_num", tf_max_num);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delReaderActionPerformed(e, map);}else{i = Jcwh.btn_saveReaderActionPerformed(e,map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "读者添加成功!";}else if(optionStr.equals("update")){showInfo = "读者修改成功!";}else if(optionStr.equals("delete")){showInfo = "读者删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setTitle("添加读者信息");setSize(500, 230);lbreaderid.setBounds(50, 50, 50, 20);tf_readerid.setBounds(110, 50, 100, 20);lbreadername.setBounds(240, 50, 50, 20);tf_readername.setBounds(300, 50, 100, 20);lbreadertype.setBounds(50, 80, 50, 20);tf_readertype.setBounds(110, 80, 100, 20);tf_readertype.add("教师");tf_readertype.add("学生");tf_readertype.add("职工");lbsex.setBounds(240, 80, 50, 20);tf_sex.setBounds(300, 80, 100, 20);tf_sex.add("男");tf_sex.add("女");lbmax_num.setBounds(50, 110, 50, 20);tf_max_num.setBounds(110, 110, 100, 20);lbdays_num.setBounds(240, 110, 50, 20);tf_days_num.setBounds(300, 110, 100, 20);saveBtn.setBounds(150, 150, 80, 25);closeBtn.setBounds(280, 150, 80, 25);if(str.equals("save")){setTitle("添加读者");}else if(str.equals("update")){setTitle("修改读者");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbreaderid);add(lbreadername);add(lbreadertype);add(lbsex);add(lbmax_num);add(lbdays_num);add(tf_readerid);add(tf_readername);add(tf_max_num);add(tf_days_num);add(tf_readertype);add(tf_sex);add(saveBtn);add(closeBtn);setLocationRelativeTo(null);setVisible(true);}private void clearAllTextfield() {tf_readerid.setText("");tf_readername.setText("");tf_max_num.setText("");tf_days_num.setText("");}public static void main(String[] args) {ReaderManeger r = new ReaderManeger("update");}}5.借书public class Borrow extends Frame {private static final long serialVersionUID = -1036076990599464079L;String SepLine = "-------------------------------------------------";Label lbbookid = new Label("图书编号");Label lbreaderid = new Label("读者编号");TextField tf_bookid = new TextField();TextField tf_readerid = new TextField();Button queryBtn = new Button("查询");Label lbbookinfo = new Label(SepLine + "图书信息" + SepLine); Label lbbookname = new Label("图书名称:");Label tf_bookname = new Label("xx");Label lbauthor = new Label("作者:");Label tf_author = new Label("xx");Label lbpublisher = new Label("出版社:");Label tf_publisher = new Label("xx");Label lbpublish_time = new Label("出版时间:");Label tf_publish_time = new Label("xx");Label lbprice = new Label("定价:");Label tf_price = new Label("xx");Label lbstock = new Label("库存数量:");Label tf_stock = new Label("xx");Label lbreaderinfo = new Label(SepLine + "读者信息" + SepLine); Label lbreadername = new Label("读者姓名:");Label tf_readername = new Label("xx");Label lbreadertype = new Label("读者类型:");Label tf_readertype = new Label("xx");Label lbmax_num = new Label("最大可借数:");Label tf_max_num = new Label("xx");Label lbdays_num = new Label("最大可借天数:");Label tf_days_num = new Label("xx");Label lbborrowinfo = new Label(SepLine + "借阅信息" + SepLine); Label lbborrowednum = new Label("该读者已借图书数量:"); Label tf_borrowednum = new Label("xx");Label lbif_borrow = new Label("该读者是否可借所选图书:"); Label tf_if_borrow = new Label("xx");Label lbborrow_date = new Label("借阅日期:");Label tf_borrow_date = new Label("xx");Button borrowBtn = new Button("借出");Button closeBtn = new Button("关闭");public Borrow() {setLayout(null);setTitle("借阅图书");setSize(500, 420);this.setForeground(Color.BLACK); // 设置前景色为黑色lbbookid.setBounds(30, 40, 50, 25); // 图书编号tf_bookid.setBounds(90, 40, 90, 20);lbreaderid.setBounds(200, 40, 50, 25); // 读者编号tf_readerid.setBounds(260, 40, 90, 20);queryBtn.setBounds(370, 40, 80, 25); // 查询按钮lbbookinfo.setBounds(30, 70, 440, 25); // 图书信息提示条lbbookname.setBounds(30, 100, 60, 25); // 图书名称tf_bookname.setBounds(90, 100, 200, 25);lbauthor.setBounds(310, 100, 60, 25); // 作者tf_author.setBounds(370, 100, 90, 25);lbpublisher.setBounds(30, 125, 60, 25); // 出版社tf_publisher.setBounds(90, 125, 200, 25);lbpublish_time.setBounds(310, 125, 60, 25); // 出版时间tf_publish_time.setBounds(370, 125, 90, 25);lbprice.setBounds(30, 150, 60, 25); // 定价tf_price.setBounds(90, 150, 200, 25);lbstock.setBounds(310, 150, 60, 25); // 库存数量tf_stock.setBounds(370, 150, 90, 25);lbreaderinfo.setBounds(30, 180, 440, 25); // 读者信息提示条lbreadername.setBounds(30, 205, 60, 25); // 读者姓名tf_readername.setBounds(90, 205, 90, 25);lbreadertype.setBounds(310, 205, 60, 25); // 读者类型tf_readertype.setBounds(370, 205, 90, 25);lbmax_num.setBounds(30, 230, 75, 25); // 最大可借数tf_max_num.setBounds(105, 230, 90, 25);lbdays_num.setBounds(310, 230, 85, 25); // 最大可借天数tf_days_num.setBounds(395, 230, 70, 25);lbborrowinfo.setBounds(30, 260, 440, 25); // 借阅信息提示条lbborrowednum.setBounds(30, 285, 120, 25);// 已借图书数量tf_borrowednum.setBounds(150, 285, 50, 25);lbif_borrow.setBounds(30, 310, 145, 25); // 是否可借tf_if_borrow.setBounds(175, 310, 50, 25);lbborrow_date.setBounds(30, 335, 60, 25);// 借书日期tf_borrow_date.setBounds(90, 335, 100, 25);borrowBtn.setBounds(160, 365, 80, 25);// 借出按钮borrowBtn.setEnabled(false); // 开始时禁用借出按钮closeBtn.setBounds(260, 365, 80, 25);// 关闭按钮queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_querywActionPerformed(e); } }); borrowBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_borrowActionPerformed(e); } });closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { setForeground(Color.BLACK); dispose(); } }); this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {setForeground(Color.BLACK); // 设置前景色为黑色dispose(); // 关闭窗体}});add(lbbookid);add(lbreaderid);add(queryBtn);add(lbbookinfo);add(lbbookname);add(lbauthor);add(lbpublisher);add(lbpublish_time);add(lbprice);add(lbstock);add(lbreaderinfo);add(lbreadername);add(lbreadertype);add(lbmax_num);add(lbdays_num);add(lbborrowinfo);add(lbborrowednum);add(lbif_borrow);add(lbborrow_date);add(borrowBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见setForeground(Color.RED); // 设置前景色为红色add(tf_bookid);add(tf_readerid);add(tf_bookname);add(tf_author);add(tf_publisher);add(tf_publish_time);add(tf_price);add(tf_stock);add(tf_readername);add(tf_readertype);add(tf_max_num);add(tf_days_num);add(tf_borrowednum);add(tf_if_borrow);add(tf_borrow_date);}// 图书和读者查询private void btn_querywActionPerformed(ActionEvent e) {String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();// 如果图书编号或读者编号两者均为空,或者有一个为空,则返回if (bookid.equals("") || readerid.equals("")) {JOptionPane.showMessageDialog(null, "图书编号和读者编号均不能为空!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询图书,结果存入book对象中Book book = BookSelect.SelectBookById(bookid);if (book != null) { // 如果查询到结果,将其显示在各文本框中tf_bookname.setText(book.getBookname());tf_author.setText(book.getAuthor());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf((book.getPrice())));tf_stock.setText(String.valueOf(book.getStock()));} else {JOptionPane.showMessageDialog(null, "图书编号有误,查无此书!");init(); // 重新初始化各参数并禁止借出按钮return;}if (book.getStock() == 0) {JOptionPane.showMessageDialog(null, "图书已无库存,无法借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询读者,结果存入reader对象中Reader reader = ReaderSelect.selectReaderById(readerid);// 如果查询到结果,将其显示在各文本框中if (reader != null) {tf_readername.setText(reader.getReadername());tf_readertype.setText(reader.getReadertype());tf_max_num.setText(String.valueOf(reader.getMax_num()));tf_days_num.setText(String.valueOf(reader.getDays_num()));} else {JOptionPane.showMessageDialog(null, "读者编号有误,查无此人!");init(); // 重新初始化各参数并禁止借出按钮return;}// 查询指定读者是否已借过指定图书且未归还if (IfBorrowBack.findbook(bookid, readerid)) {JOptionPane.showMessageDialog(null, "该读者已借阅所选图书,且未归还!");init(); // 重新初始化各参数并禁止借出按钮return;}// 统计读者所借图书数量int borrowednum = statborrowednum(readerid);tf_borrowednum.setText(String.valueOf(borrowednum));// 如果读者已借图书尚未超出其允许最大借书量,则允许其继续借阅所选图书if (borrowednum < reader.getMax_num()) {tf_if_borrow.setText("是");// 创建一个简单日期格式对象,注意:MM一定要用大写SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 创建日期变量,其内容为当前日期Date currentdate = new Date();// 将日期按指定格式输出String borrowdate = sdf.format(currentdate);tf_borrow_date.setText(borrowdate);borrowBtn.setEnabled(true); // 使借出按钮有效} else {JOptionPane.showMessageDialog(null, "该读者借书过多,无法继续借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}}// 填写借出图书记录private void btn_borrowActionPerformed(ActionEvent e) {String sql;String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();String borrowdate = tf_borrow_date.getText();// 为borrow表增加借书记录sql = "insert into borrow (book_id,reader_id,"+ "borrow_date,if_back) values('" + bookid + "','" + readerid + "','" + borrowdate + "','否')";。

java课程设计图书馆管理系统代码

java课程设计图书馆管理系统代码

Java课程设计:图书馆管理系统代码介绍本文档是关于使用Java编写的图书馆管理系统代码的设计和实现。

图书馆管理系统是一种用于管理图书馆藏书、借还书籍和读者信息的应用程序。

它可以帮助图书馆提高管理效率和服务质量,并提供方便的读者查询和借还书的功能。

功能和需求1.用户管理:图书馆管理员可以添加、删除和编辑读者信息,包括姓名、联系方式和借书情况等。

2.图书管理:管理员可以添加、删除和编辑图书信息,包括书名、作者、出版日期和库存数量等。

3.借书和还书功能:读者可以借阅图书,管理员可以归还已借出的图书,并更新库存数量。

4.图书查询功能:读者可以根据图书名称、作者或出版日期等条件进行图书查询,以了解图书的详细信息和当前库存情况。

5.借阅记录查询:管理员可以查询读者的借阅记录,包括借阅时间、归还时间和借阅状态等。

系统设计数据模型系统设计采用面向对象的编程思想,主要包括以下几个类:图书馆类(Library)•属性:–读者列表(Reader[] readers)–图书列表(Book[] books)•方法:–添加读者(addReader)–删除读者(removeReader)–编辑读者信息(editReader)–添加图书(addBook)–删除图书(removeBook)–编辑图书信息(editBook)–借书(borrowBook)–还书(returnBook)–图书查询(searchBook)–借阅记录查询(searchRecords)读者类(Reader)•属性:–姓名(String name)–联系方式(String contact)–借阅记录列表(Record[] records)•方法:–借书(borrowBook)–还书(returnBook)图书类(Book)•属性:–书名(String title)–作者(String author)–出版日期(Date publicationDate)–库存数量(int quantity)•方法:–增加库存(increaseQuantity)–减少库存(decreaseQuantity)借阅记录类(Record)•属性:–图书(Book book)–读者(Reader reader)–借阅日期(Date borrowDate)–归还日期(Date returnDate)•方法:–设置归还日期(setReturnDate)系统流程图下图展示了图书馆管理系统的基本流程:graph LRA[开始] --> B[登录]B --> C{用户类型}C -->|管理员| E[管理图书馆]C -->|读者| F[查询图书]F --> G{查询类型}G -->|书名| H[查询结果]G -->|作者| H[查询结果]G -->|出版日期| H[查询结果]F --> I[返回主菜单]I --> FE --> J{操作类型}J -->|添加读者| K[输入读者信息]K --> L[保存读者信息]J -->|删除读者| M[输入读者ID]M --> N[删除读者信息]J -->|编辑读者| O[输入读者ID]O --> P[输入更新信息]P --> Q[更新读者信息]J -->|添加图书| R[输入图书信息]R --> S[保存图书信息]J -->|删除图书| T[输入图书ID]T --> U[删除图书信息]J -->|编辑图书| V[输入图书ID]V --> W[输入更新信息]W --> X[更新图书信息]J -->|借书| Y[输入读者ID和图书ID]Y --> Z[创建借阅记录]J -->|还书| A1[输入借阅记录ID]A1 --> B1[设置归还日期]B1 --> C1[更新借阅记录]J -->|查询借阅记录| D1[输入读者ID]D1 --> E1[查询借阅记录信息]代码实现以下是Java图书馆管理系统的代码实现:public class Library {private Reader[] readers;private Book[] books;public void addReader(Reader reader) {// 添加读者}public void removeReader(int readerId) {// 删除读者}public void editReader(int readerId, Reader reader) { // 编辑读者信息}public void addBook(Book book) {// 添加图书}public void removeBook(int bookId) {// 删除图书}public void editBook(int bookId, Book book) { // 编辑图书信息}public void borrowBook(int readerId, int bookId) { // 借书}public void returnBook(int recordId) {// 还书}public Book[] searchBook(String keyword) {// 图书查询}public Record[] searchRecords(int readerId) { // 借阅记录查询}}public class Reader {private String name;private String contact;private Record[] records;public void borrowBook(int bookId) {// 借书}public void returnBook(int recordId) {// 还书}}public class Book {private String title;private String author;private Date publicationDate;private int quantity;public void increaseQuantity(int amount) {// 增加库存}public void decreaseQuantity(int amount) {// 减少库存}}public class Record {private Book book;private Reader reader;private Date borrowDate;private Date returnDate;public void setReturnDate(Date returnDate) {// 设置归还日期}}快速开始编译和运行图书馆管理系统的示例代码,请按照以下步骤:1.准备Java开发环境。

用java做的一个图书管理系统的源代码.doc

用java做的一个图书管理系统的源代码.doc

用 java 做的一个图书管理系统的源代码import .*;import .*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner;"请输入用户名:");String username2=();"请输入密码:");String password2=();if(!("")||(""))){try{("");conn=("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=();rs=(sql);if()){if("password").equals(password2)){"*********欢迎来山东科技大学图书馆管理系统********");while(true){" 1.图书信息");" 2. 读者信息");" 3. 管理员信息");" 4.借阅信息");" 5. 还书信息");" 6.逾期罚款或损坏赔偿信息");出");" 请输入选择功能的序号:"); int a=();switch(a){case 1:" 图书信息 : ");" 1. 查询图书信息 : ");" 2. 插入图书信息 : ");" 3. 删除图书信息 : ");" 4. 修改图书信息 : ");int a1=();switch(a1){case 1:" " "欢迎进入图书信息查询系统1. 无条件查询图书信息:2. 条件查询图书信息::");");");int d=();switch(d){case 1:int llll=0;无条件查询图书信息:");String Sql0 = "SELECT * FROM systembook ";rs= (Sql0);while()){String bookID =(1);String bookNo =(2);String bookName =(3);String bookWriter =(4);String bookPub =(5);","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}"是否继续插入 yes/no no 返回主菜单 ");String k=();if("yes"))};if("no")){llll=1;};}break;条件查询图书信息 : ");" 1. 单条件查询图书信息: ");" 2. 模糊条件查询图书信息: ");" 3. 多表连接查询图书信息: ");" 4. 嵌套查询图书信息 : ");" 5. 谓词演算查询");int c12=();switch(c12){case 1:" 1.单条件查询 :");" 1.按图书名编码号查询图书信息:");int ddd=0;while(ddd!=1){"请输入图书编码号:");String A=();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= (sql1);int x=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){" 查无此书 ,请重新输入 ");else{"是否继续按姓名查询yes/no no 返回主菜单 ");String k=();if("yes")){};if("no")){ddd=1;};};}break;case 2:" 2.模糊查询图书信息:");int dc=0;while(dc!=1){" 请用户输入图书名字中的模糊关键字");String E=();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= (sq123);int z=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){" 查无此书 ,请重新输入 ");}else{"是否继续输入图书名字中的模糊关键字yes/no no 返回主菜单 ");String k=();if("yes")){};if("no")){dc=1;表连接查询查询图书信息: ");int dq=0;while(dq!=1){" 查询逾期罚款或是赔偿表中的读者的相关信息");" 请输入逾期罚款或是赔偿的读者编码号");String F=();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE = AND = AND ='"+F+"' ";rs= (sq1234);int n=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){" 查无此人 ,请重新输入 ");}else{" 是否继续输入图书名字中的模糊关键字yes/no no 返回主菜单 ");if("yes")){};if("no")){ddd=1;};}}break;case 4:" 4.嵌套查询图书信息:");int dq1=0;while(dq1!=1){"查询某读者所在年级女读者的相关信息");"请输入某读者的读者编号");String G=();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'"; rs= (sq12345);int m=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){" 查无此书 ,请重新输入 ");}else{"是否继续输入读者编号yes/no no 返回主菜单 ");if("yes")){};if("no")){d=1;};}}break;case 5:" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){"查询借阅了某本书的读者的相关信息");"请输入该书的名字");String H=();String sq123456= "SELECT* FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= (sq123456);int l=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){" 查无此人 ,请重新输入 ");}else{" 是否继续输入图书名字yes/no no 返回主菜单");String k=();if("yes")){} ;if("no")){d=1;};}}break;}查询图书信息 :");String Sql = "SELECT * FROM systembook ";rs= (Sql);while()){插入图书信息: " 请按顺序插入图书条码号");,图书索书号,图书名字,图书作者,图书出版社");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=(insertSql);删除图书信息:");"请输入要删除的图书编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHEREbookID='"+b3+"'";int p=(deleSql);修改图书信息:");"请输入修改的图书ID");String S=();String sql1="SELECT * FROM systembook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这本书,请重新输入");}else{"要将书名改为");String bbb=();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=(updateSql1);查询读者信息" 2. 插入读者信息 :");" 3. 删除读者信息 :");" 4. 修改读者信息:"int b1=();switch(b1){case 1:" 1. 查询读者信息 :"); :);");String ssql = "SELECT * FROM systemreader ";rs= (ssql);while()){插入读者信息 :");"请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=();String []splitst=(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTOsystemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"' ,'"+b20+"')";int n=(insertSql);删除读者信息:");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);String g22 =(7);String h22 =(8);String i22 =(9);","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){"没有这个读者,请重新输入");}else{修改读者信息:");"请输入修改以后的读者的ID ");String S=();查询管理员信息 : ");" 2. 插入管理员信息 : ");" 3. 删除管理员信息 : ");" 4. 修改管理员信息 : ");" 5. 返回上一级");int c11=();switch(c11){case 1:" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= (Ssql);while()){插入管理员信息 :");" 请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTOmanager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=(insertSql);删除管理员信息:");"请输入要删除的管理员编号 :");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这个管理员,请重新输入");}else{修改管理员信息: ");" 请输入要修改的管理员编号:");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这个管理员,请重新输入");}else{查询图书借阅信息信息: ");" 2. 插入图书借阅信息 : ");" 3. 删除图书借阅信息 : ");" 4. 修改图书借阅信息 : ");" 5. 返回上一级");int d=();switch(d){case 1:" 1. 查询图书借阅信息:");String Sql4 = "SELECT * FROM borrowbook ";rs= (Sql4);while()){String bookID =(1);String reaID =(2);String outDate =(3);String yhDate =(4);","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){" 2. 插入图书借阅信息:");"请按顺序插入图书的的编号 ,读者编号 ,图书借出日期 ,图书归还日期 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书借阅信息:");"请输入要删除的图书条码号 :");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);修改借阅读书信息:");"请输入要修改的图书的 ID ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);查询还书信息 : ");" 2. 插入还书信息 : ");" 3. 删除还书信息 : ");" 4. 修改还书信息 : ");" 5. 返回上一级");int e=();switch(e){case 1:"1. 查询还书信息 : ");sql = "SELECT * FROM return ";rs= (sql);while()){String reaID =(1);String bookID =(2);String bookName =(3);String inDate =(4);","+bookID+","+bookName+","+ inDate);}break;case 2:" 2. 插入还书信息:");"请按顺序插入读者卡号 ,图书编号 ,图书名称 ,还书日期 ");String str=();String []splitst=(",");String e1=splitst[0];String e2=splitst[1];String e3=splitst[2];String e4=splitst[3];String insertSql="INSERT INTO returnbook(reaID,bookID,bookName,inDate) VALUES('"+e1+"','"+e2+"','"+e3+"','"+e4+"')";int h=(insertSql); 删除还书书信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String f3=Splitst[0];String deleSql= "DELETE FROM return WHERE reaID='"+f3+"'";int w=(deleSql);查询罚款信息:");" 2. 插入罚款信息 : ");" 3. 删除罚款信息 : ");" 4. 修改罚款信息 : ");int g=();switch(g){case 1:"1. 查询罚款信息 : ");String Sssql = "SELECT * FROM fine ";rs= (Sssql);while()){插入罚款信息 : ");" 请按顺序插入读者卡号 , 图书编号 ,借书日期,超出日期 ,应缴罚款 ");String str=();String []splitst=(",");String g1=splitst[0];String g2=splitst[1];String g3=splitst[2];String g4=splitst[3];String g5=splitst[4];删除罚款信息 : ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String deleSql= "DELETE FROM fine WHERE reaID='"+r+"'";int x=(deleSql); 查询借阅历史信息 : ");" 2. 插入借阅历史信息 : ");" 3. 删除借阅历史信息 : ");" 4. 修改借阅历史信息 : ");" 5. 返回上一级");int h=();switch(h){case 1:" 1. 查询历史借阅信息:");String Sql7 = "SELECT * FROM borrowhistory ";rs= (Sql7);while()){String bookID =(1);String reaID =(2);String bookName=(3);String bookWriter=(4);String outDate =(5);String yhDate =(6);","+reaID+","+bookName+","+bookWriter+","+outDate+","+yhDate);}break;case 2:" 2. 插入图书历史借阅信息:");"请按顺序插入图书的的编号 ,读者编号 ,,图书借出日期 ,图书归还日期 ");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书历史借阅信息:");" 请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String d3=Splitst[0];String deleSql= "DELETE bookID FROM borrowhistory WHERE bookID='"+d3+"'";int k=(deleSql);修改图书借阅历史信息" 请输入要修改的图书的借出日期String S=();:");");String []Ssplitst=(",");String c1=Ssplitst[0];String updateSql="UPDATE borrow SET outDate='"+c1+"' WHERE bookName=' 数据库 '";int t=(updateSql); // 返回记录影响的条数if(t!=0){" 修改成功 !");}break;}}}}}else{"非法用户! ");}}catch(SQLException e) {();}//();();();}}}}。

用java做的一个图书管理系统的源代码

用java做的一个图书管理系统的源代码

用j a v a做的一个图书管理系统的源代码标准化文件发布号:(9312-EUATWW-MWUB-WUNN-INNUL-DQQTY-用java做的一个图书管理系统的源代码import .*;import .*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner;"请输入用户名:");String username2=();"请输入密码:");String password2=();if(!("")||(""))){try{("");conn=("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'"; stmt=();rs=(sql);if()){if("password").equals(password2)){"*********欢迎来山东科技大学图书馆管理系统********"); while(true){" 1.图书信息 ");" 2.读者信息 ");" 3.管理员信息 ");" 4.借阅信息 ");" 5.还书信息 ");" 6.逾期罚款或损坏赔偿信息");出 ");" 请输入选择功能的序号 :");int a=();switch(a){case 1:" 图书信息: ");" 1. 查询图书信息: ");" 2. 插入图书信息: ");" 3. 删除图书信息: ");" 4. 修改图书信息: ");int a1=();switch(a1){case 1:" 欢迎进入图书信息查询系统: ");" 1. 无条件查询图书信息: ");" 2. 条件查询图书信息: ");int d=();switch(d){case 1:int llll=0;无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= (Sql0);while()){String bookID =(1);String bookNo =(2);String bookName =(3);String bookWriter =(4);String bookPub =(5);","+bookNo+","+bookName+","+ bookWriter+","+bookPub); }"是否继续插入yes/no no返回主菜单");String k=();if("yes")){};if("no")){llll=1;};}break;条件查询图书信息: ");" 1. 单条件查询图书信息: ");" 2. 模糊条件查询图书信息: ");" 3. 多表连接查询图书信息: ");" 4. 嵌套查询图书信息: ");" 5. 谓词演算查询 ");int c12=();switch(c12){case 1:" 1.单条件查询: ");" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){"请输入图书编码号:");String A=();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= (sql1);int x=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){"查无此书,请重新输入");}else{"是否继续按姓名查询yes/no no返回主菜单");String k=();if("yes")){};if("no")){ddd=1;};};}break;case 2:" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){"请用户输入图书名字中的模糊关键字");String E=();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= (sq123);int z=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){"查无此书,请重新输入");else{"是否继续输入图书名字中的模糊关键字yes/no no返回主菜单");String k=();if("yes")){};if("no")){dc=1;表连接查询查询图书信息: ");int dq=0;while(dq!=1){"查询逾期罚款或是赔偿表中的读者的相关信息");"请输入逾期罚款或是赔偿的读者编码号");String F=();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE = AND = AND ='"+F+"' ";rs= (sq1234);int n=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){"查无此人,请重新输入");}else{"是否继续输入图书名字中的模糊关键字yes/no no返回主菜单");String k=();if("yes")){};if("no")){ddd=1;};}}break;case 4:" 4.嵌套查询图书信息: ");int dq1=0;while(dq1!=1){"查询某读者所在年级女读者的相关信息");"请输入某读者的读者编号");String G=();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= (sq12345);int m=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){"查无此书,请重新输入");}else{"是否继续输入读者编号yes/no no返回主菜单");String k=();if("yes"))};if("no")){d=1;};}}break;case 5:" 5. 谓词演算查询: ");int dq1123=0;while(dq1123!=1){"查询借阅了某本书的读者的相关信息");"请输入该书的名字");String H=();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= (sq123456);int l=0;while()){String a2 =(1);String b2 =(2);String c2 =(3);String d2 =(4);String e2 =(5);","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){"查无此人,请重新输入");}else{"是否继续输入图书名字yes/no no返回主菜单");String k=();if("yes")){};if("no")){d=1;};}}break;}查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= (Sql);while()){插入图书信息: ");"请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTOsystembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=(insertSql); 删除图书信息: ");"请输入要删除的图书编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=(deleSql); 修改图书信息: ");"请输入修改的图书ID ");String S=();String sql1="SELECT * FROM systembook where bookID='"+S+"'"; rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){"没有这本书,请重新输入");}else{"要将书名改为");String bbb=();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=(updateSql1); 查询读者信息: ");" 2. 插入读者信息: ");" 3. 删除读者信息: ");" 4. 修改读者信息: " );int b1=();switch(b1){case 1:" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= (ssql);while()){插入读者信息: ");"请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=();String []splitst=(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTOsystemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPr e,reaDate)VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18 +"','"+b19+"','"+b20+"')";int n=(insertSql); 删除读者信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);String g22 =(7);String h22 =(8);String i22 =(9);","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22); kkk++;}if(kkk==0){"没有这个读者,请重新输入");}else{修改读者信息: ");"请输入修改以后的读者的ID ");String S=();查询管理员信息: ");" 2. 插入管理员信息: ");" 3. 删除管理员信息: ");" 4. 修改管理员信息: ");" 5. 返回上一级 ");int c11=();switch(c11){case 1:" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= (Ssql);while()){插入管理员信息: ");"请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTOmanager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=(insertSql); 删除管理员信息: ");"请输入要删除的管理员编号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);String e22 =(5);String f22 =(6);","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){"没有这个管理员,请重新输入");}else{修改管理员信息: ");"请输入要修改的管理员编号: ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'"; rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);String e222 =(5);String f222 =(6);","+b222+" ,"+c222+","+d222+","+e222+","+f222); lll++;}if(lll==0){"没有这个管理员,请重新输入");}else{查询图书借阅信息信息: ");" 2. 插入图书借阅信息: ");" 3. 删除图书借阅信息: ");" 4. 修改图书借阅信息: ");" 5. 返回上一级 ");int d=();switch(d){case 1:" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= (Sql4);while()){String bookID =(1);String reaID =(2);String outDate =(3);String yhDate =(4);","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){" 2. 插入图书借阅信息: ");"请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书借阅信息: ");"请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= (sql1);int kkk=0;while()){String a22 =(1);String b22 =(2);String c22 =(3);String d22 =(4);修改借阅读书信息: ");"请输入要修改的图书的ID ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= (sql1);int lll=0;while()){String a222 =(1);String b222 =(2);String c222 =(3);String d222 =(4);查询还书信息: ");" 2. 插入还书信息: ");" 3. 删除还书信息: ");" 4. 修改还书信息: ");" 5. 返回上一级 ");int e=();switch(e){case 1:" 1. 查询还书信息: ");sql = "SELECT * FROM return ";rs= (sql);while()){String reaID =(1);String bookID =(2);String bookName =(3);String inDate =(4);","+bookID+","+bookName+","+ inDate);}break;case 2:" 2. 插入还书信息: ");"请按顺序插入读者卡号,图书编号,图书名称,还书日期");String str=();String []splitst=(",");String e1=splitst[0];String e2=splitst[1];String e3=splitst[2];String e4=splitst[3];String insertSql="INSERT INTOreturnbook(reaID,bookID,bookName,inDate)VALUES('"+e1+"','"+e2+"','"+e3+"','"+e4+"')";int h=(insertSql); 删除还书书信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String f3=Splitst[0];String deleSql= "DELETE FROM return WHERE reaID='"+f3+"'";int w=(deleSql); 查询罚款信息: ");" 2. 插入罚款信息: ");" 3. 删除罚款信息: ");" 4. 修改罚款信息: ");int g=();switch(g){case 1:" 1. 查询罚款信息: ");String Sssql = "SELECT * FROM fine ";rs= (Sssql);while()){插入罚款信息: ");"请按顺序插入读者卡号,图书编号,借书日期,超出日期,应缴罚款");String str=();String []splitst=(",");String g1=splitst[0];String g2=splitst[1];String g3=splitst[2];String g4=splitst[3];String g5=splitst[4];删除罚款信息: ");"请输入要删除的读者证号:");String Str=();String []Splitst=(",");String r=Splitst[0];String deleSql= "DELETE FROM fine WHERE reaID='"+r+"'";int x=(deleSql); 查询借阅历史信息: ");" 2. 插入借阅历史信息: ");" 3. 删除借阅历史信息: ");" 4. 修改借阅历史信息: ");" 5. 返回上一级 ");int h=();switch(h){case 1:" 1. 查询历史借阅信息: ");String Sql7 = "SELECT * FROM borrowhistory ";rs= (Sql7);while()){String bookID =(1);String reaID =(2);String bookName=(3);String bookWriter=(4);String outDate =(5);String yhDate =(6);","+reaID+","+bookName+","+bookWriter+","+outDate+","+yhDate);}break;case 2:" 2. 插入图书历史借阅信息: ");"请按顺序插入图书的的编号,读者编号,,图书借出日期,图书归还日期");String str=();String []splitst=(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];删除图书历史借阅信息: ");"请输入要删除的图书条码号:");String Str=();String []Splitst=(",");String d3=Splitst[0];String deleSql= "DELETE bookID FROM borrowhistory WHEREbookID='"+d3+"'";int k=(deleSql); 修改图书借阅历史信息: ");"请输入要修改的图书的借出日期 ");String S=();String []Ssplitst=(",");String c1=Ssplitst[0];String updateSql="UPDATE borrow SET outDate='"+c1+"' WHERE bookName='数据库'";int t=(updateSql); //返回记录影响的条数if(t!=0){"修改成功!");}break;}}}}}else{"非法用户!");}}catch(SQLException e) { ();}//();();();}}}}。

java编写的图书管理系统源代码

java编写的图书管理系统源代码

/用户登陆数据库代码:importjava.sql.*;classDatabase{Connectioncon;ResultSetrs;Statementstmt;publicDatabase(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:HDB";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt= //con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,//ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/*根据用户名,获取密码*/publicStringgetPswd(Stringname){try{//rs为执行SQL语句所查询的结果赋给结果集对象rsrs=stmt.executeQuery("SELECTpswdFROMUserWHEREName='"+name+"'");st();//把rs的指针移到最后一行if(rs.getRow()==0){returnnull;}else{StringpswdDB=rs.getString("Pswd");//获取rs结果集中的pswd列的数据returnpswdDB;}}catch(Exceptione){System.out.println(e);returnnull;}}/*增加一行用户名、密码数据*/publicbooleaninsertData(Stringname,Stringpswd){try{Strings=getPswd(name);if(s==null){intrtn=stmt.executeUpdate("INSERTINTOUserVALUES('"+name+"','"+pswd+"')");if(rtn!=0)returntrue;}else{returnfalse;}returnfalse;}catch(Exceptionet){System.out.println(et);returnfalse;}}}//进库数据库代码:importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;classBookDatabase{Connectioncon;ResultSetrs;Statementstmt;publicBookDatabase(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/*增加一行用户名、密码数据*/publicbooleaninsertData(Stringid,Stringname,Stringwhere,Stringprice,Stringdate){try{intrtn=stmt.executeUpdate("INSERTINTOBookVALUES('"+id +"','"+name+"','"+where+"','"+price+"','"+date+"')");if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exceptionet){System.out.println(et);returnfalse;}}/**publicbooleandeleteData(Stringid){try{intrtn=*stmt.executeUpdate("DELETEFROMBookWHEREid=001");if(rtn!=0){ *returntrue;}else{returnfalse;}}catch(Exceptione){*System.out.println(e);returnfalse;}}publicbooleanSelect(String*id){try{intrtn=stmt.executeUpdate("SELECT*FROMBookInWHERE *id='"+id+"'");**if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exception*e){System.out.println(e);returnfalse;}}*/}//出库数据库代码:importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.Statement;classBookDatabase1{Connectioncon;ResultSetrs;Statementstmt;publicBookDatabase1(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbcdbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}/**增加一行用户名、密码数据publicbooleaninsertData(Stringid,Stringname,String*where,String**price,Stringdate){try{intrtn=stmt.executeUpdate("INSERTINTO*BookInVALUES('"+id+**"','"+name+"','"+where+"','"+price+"','"+date+"')");**if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exception*et){System.out.println(et);returnfalse;}}*/publicbooleandeleteData(Stringid){try{intrtn=stmt.executeUpdate("DELETEFROMBookWHEREid='"+id+"'");if(rtn!=0){returntrue;}else{returnfalse;}}catch(Exceptione){System.out.println(e);returnfalse;}}/**publicbooleanSelect(Stringid){try{intrtn=*stmt.executeUpdate("SELECT*FROMBookInWHEREid='"+id+"'");if(rtn!=*0){returntrue;}else{returnfalse;}}catch(Exceptione){*System.out.println(e);returnfalse;}}*/}//查询数据库代码;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;classBookDatabase2extendsJFrame{Stringnumber,name,address,prices,day;Connectioncon;Statementstmt=null;ResultSetresult=null;Stringsql=null;publicBookDatabase2(){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//加载JDBC-ODBC桥驱动程序Stringurl="jdbc:odbc:Book";con=DriverManager.getConnection(url);//连接数据库HDB//stmt提供一个创建SQL查询、执行查询、得到返回结果的空间stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);}catch(Exceptionex){System.out.println(ex);}}publicvoidselect(Stringid){try{sql="SELECT*FROMBookwhereid='"+id+"'";result=stmt.executeQuery(sql);while(result.next()){number=result.getString(1);name=result.getString(2);address=result.getString(3);prices=result.getString(4);day=result.getString(4);}JOptionPane.showMessageDialog(BookDatabase2.this,"成功查询图书!\n"+"图书ID:"+number+"\n"+"图书名称:"+name+"\n"+"出版社"+address+"\n"+"价格:"+prices+"\n"+"出版日期:"+day+"\n","提示",JOptionPane.ERROR_MESSAGE);}catch(Exceptione){System.out.println(e);}}。

图书借阅管理系统java代码

图书借阅管理系统java代码

以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书借阅管理系统java代码# 图书借阅管理系统Java代码## 一、介绍图书借阅管理系统是一个帮助图书馆管理图书借阅情况的系统。

本系统基于Java开发,采用面向对象的编程方式,实现了对图书信息、借阅记录等数据的管理与处理。

用户可以通过该系统查询图书信息、借阅图书、归还图书,并实现了管理员对系统的管理功能。

## 二、功能模块### 1. 图书管理模块- 实现对图书信息的添加、删除、修改和查询功能。

- 对图书的分类管理,方便用户按照分类查找图书信息。

### 2. 用户管理模块- 用户注册与登录功能,保证用户数据的安全。

- 用户查询借阅情况、借阅历史等个人信息。

### 3. 借阅管理模块- 实现图书的借阅功能,包括借书日期、归还日期等信息的记录。

- 用户借阅超时提醒,确保图书及时归还。

### 4. 管理员模块- 管理员登录后可以对图书信息、用户信息进行管理。

- 实现图书归还、逾期处理等功能。

## 三、系统架构本系统采用MVC(Model-View-Controller)架构,实现了模型层、视图层、控制层之间的分离,提高了系统的灵活性和可维护性。

具体架构如下:1. Model层:负责处理数据的逻辑操作,包括对图书信息、用户信息、借阅记录等数据的管理。

2. View层:负责系统的界面展示,包括用户界面和管理员界面。

3. Controller层:负责处理用户请求,调用Model层的方法,并将结果返回给View层进行展示。

## 四、代码示例以下是借阅图书的Java代码示例:```javapublic class BorrowBook {private Book book;private User user;private Date borrowDate;private Date returnDate;// Constructorpublic BorrowBook(Book book, User user, Date borrowDate, Date returnDate) {this.book = book;er = user;this.borrowDate = borrowDate;this.returnDate = returnDate;}// Getters and setters}```以上代码实现了一个借阅图书的类`BorrowBook`,包含了借阅的图书信息、用户信息,借阅时间和归还时间。

java书店管理系统源代码

java书店管理系统源代码

Java 源代码publicclass loaduser {public String user;public String password;boolean b1;loaduser(String s1,String s2){user=s1;password=s2;}void load(){System.out。

println(" 书店管理销售系统");System.out.println(”**************************************");System。

out。

println(” 1、登录系统”);System.out.println(” 2、退出系统”);System。

out.println("**************************************”);System。

out.println("请选择:”);int m;Scanner s=new Scanner(System。

in);m=s。

nextInt();if(m==1){for(int i=0;i〈3;i++){System.out。

println("请输入账户名和密码”);String s3,s4;Scanner ss=new Scanner(System。

in);s3=s。

next();s4=s。

next();if(user。

equals(s3)&&password.equals(s4)) b1=true;else b1=false;if(i==0&&b1==false)System。

out.println("用户名或密码输入错误一次,还有两次机会!”);if(i==1&&b1==false)System。

out。

println(”用户名或密码输入错误两次,还有一次机会!");if(i==2&&b1==false){System.out.println(”三次输入错误,退出系统!”);System。

java实现简易的图书馆管理系统

java实现简易的图书馆管理系统

java实现简易的图书馆管理系统⽐较适合新⼿练⼿的⼀个简易项⽬直接上源码Bookpackage code;/*** @author ztr* @version创建时间:2021年3⽉4⽇下午8:21:40* 类说明*/public class Book {private String name;private String author;private double price;private String type;// 有参构造器public Book(String name, String author, double price, String type) {super(); = name;this.author = author;this.price = price;this.type = type;}public String getName() {return name;}public void setName(String name) { = name;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public String getType() {return type;}public void setType(String type) {this.type = type;}}Cuserpackage code;import java.util.Iterator;import java.util.List;import java.util.Scanner;/*** @author ztr* @version创建时间:2021年3⽉4⽇下午8:32:15 类说明*/public class Cuser extends User {Scanner sc = new Scanner(System.in);public Cuser(String name, String sex, int age) {super(name, sex, age);}// 查找书籍@Overridepublic void serach(List<Book> LibraryBookDate) {// Scanner sc = new Scanner(System.in);System.out.println("请输⼊你想要查询的书籍名称");String name = sc.next();for (int i = 0; i < LibraryBookDate.size(); i++) {if (name != null) {if (LibraryBookDate.get(i).getName().equals(name)) {System.out.println("查询成功");System.out.println(LibraryBookDate.get(i).getName() + " " + LibraryBookDate.get(i).getAuthor() + " "+ LibraryBookDate.get(i).getPrice() + " "+ LibraryBookDate.get(i).getType());}} else {System.out.println("没有此书");}}}//遍历图书@Overridepublic void display(List<Book> LibraryBookDate) {// 使⽤lambda表达式Iterator<Book> it = LibraryBookDate.iterator();while (it.hasNext()) {// 因为it.next()返回的是object类型所以需要进⾏类型强转Book book = (Book) it.next();System.out.println(book.getName() + " " + book.getAuthor() + " " + book.getPrice() + " " + book.getType());}}//借阅书籍@Overridepublic void borrow(List<Book> LibraryBookDate) {// Scanner sc = new Scanner(System.in);System.out.println("请输⼊你想要借阅的书籍书名:");String name = sc.next();// 获取集合的迭代器Iterator<Book> it = LibraryBookDate.iterator();while (it.hasNext()) {Book book = (Book) it.next();if (book.getName().equals(name)) {System.out.println(book.getName() + " " + book.getAuthor() + " " + book.getPrice() + " " + book.getType());erdateBooks.add(book);it.remove();} else {System.out.println("没有该书籍");}}}// 归还书籍public void revert(List<Book> LibraryBookDate){// Scanner sc = new Scanner(System.in);System.out.println("请输⼊需要归还的书籍:");String name = sc.next();Iterator<Book> it = erdateBooks.iterator();while(it.hasNext()){Book book = (Book)it.next();if(book.getName().equals(name)){it.remove();LibraryBookDate.add(book);}}}}LibraryBookDatepackage code;import java.util.ArrayList;import java.util.List;/*** @author ztr* @version创建时间:2021年3⽉4⽇下午9:21:13* 类说明*/public class LibraryBookDate {static List<Book> LibraryBookDate = new ArrayList<Book>();}Menuackage code;import java.util.Scanner;/*** @author ztr* @version创建时间:2021年3⽉6⽇下午4:28:07 类说明*/public class Menu {public void menuRuser() {Ruser ruser = new Ruser("ztr", "man", 20);System.out.println("1.查阅书籍" + "/n" + "2.遍历书籍" + "/n" + "3.删除书籍" + "4.添加书籍" + "5.返回上⼀层");Scanner sc = new Scanner(System.in);int n = sc.nextInt();switch (n) {case 1:ruser.serach(LibraryBookDate.LibraryBookDate);menuRuser();break;case 2:ruser.display(LibraryBookDate.LibraryBookDate);menuRuser();break;case 3:ruser.borrow(LibraryBookDate.LibraryBookDate);menuRuser();break;case 4:ruser.insert(LibraryBookDate.LibraryBookDate);menuRuser();break;case 5:menu();break;default:System.out.println("请重新输⼊:");menuRuser();break;}sc.close();}public void menuCuser() {Cuser cuser = new Cuser("x", "man", 10);System.out.println("1.查阅书籍" + "/n" + "2.遍历书籍" + "/n" + "3.借阅书籍" + "4.归还书籍" + "5.返回上⼀层");Scanner sc = new Scanner(System.in);int n = sc.nextInt();switch (n) {case 1:cuser.serach(LibraryBookDate.LibraryBookDate);menuCuser();break;case 2:cuser.display(LibraryBookDate.LibraryBookDate);menuCuser();break;case 3:cuser.borrow(LibraryBookDate.LibraryBookDate);menuCuser();break;case 4:cuser.revert(LibraryBookDate.LibraryBookDate);menuCuser();break;case 5:menu();break;default:System.out.println("请重新输⼊:");menuCuser();break;}sc.close();}public void menu() {System.out.println("====图书馆管理系统===");System.out.println("1.⽤户 2.管理员 3.退出");Scanner sc = new Scanner(System.in);int n = sc.nextInt();switch (n) {case 1:menuCuser();break;case 2:menuRuser();case 3:break;default:System.out.println("请重新输⼊");break;}sc.close();}}Operatepackage code;import java.util.List;/*** @author ztr* @version创建时间:2021年3⽉4⽇下午8:25:01* 类说明*/public interface Operate {public void serach(List<Book> LibraryBookDate);public void display(List<Book> LibraryBookDate);public void borrow(List<Book> LibraryBookDate);}Ruserpackage code;import java.util.Iterator;import java.util.List;import java.util.Scanner;/*** @author ztr* @version创建时间:2021年3⽉6⽇下午3:56:25 类说明*/public class Ruser extends User {Scanner sc = new Scanner(System.in);public Ruser(String name, String sex, int age) {super(name, sex, age);}// 查找书籍@Overridepublic void serach(List<Book> LibraryBookDate) {// Scanner sc = new Scanner(System.in);System.out.println("请输⼊你想要查找的书籍书名:");String name = sc.next();// 获取集合的迭代器Iterator<Book> it = LibraryBookDate.iterator();while (it.hasNext()) {Book book = (Book) it.next();if (book.getName().equals(name)) {System.out.println(book.getName() + " " + book.getAuthor() + " " + book.getPrice() + " " + book.getType());erdateBooks.add(book);} else {System.out.println("没有该书籍");}}}// 遍历图书@Overridepublic void display(List<Book> LibraryBookDate) {// 使⽤lambda表达式Iterator<Book> it = LibraryBookDate.iterator();while (it.hasNext()) {// 因为it.next()返回的是object类型所以需要进⾏类型强转Book book = (Book) it.next();System.out.println(book.getName() + " " + book.getAuthor() + " "+ book.getPrice() + " " + book.getType());}}// 删除图书@Overridepublic void borrow(List<Book> LibraryBookDate) {// Scanner sc = new Scanner(System.in);System.out.println("请输⼊你要删除书籍的书名:");String name = sc.next();// 获取集合的迭代器Iterator<Book> it = LibraryBookDate.iterator();while (it.hasNext()) {Book book = (Book) it.next();if (book.getName().equals(name)) {System.out.println(book.getName() + " " + book.getAuthor()+ " " + book.getPrice() + " " + book.getType());it.remove();} else {System.out.println("没有该书籍");}}}// 添加图书public void insert(List<Book> libraryBookDate) {// Scanner sc = new Scanner(System.in);System.out.println("请依次输⼊锁添加书籍的信息:1.书名2.作者3价格4类型"); String name = sc.next();String author = sc.next();double price = sc.nextDouble();String type = sc.next();Book book = new Book(name, author, price, type);libraryBookDate.add(book);}}Userpackage code;/*** @author ztr* @version创建时间:2021年3⽉4⽇下午8:24:46* 类说明*/public abstract class User implements Operate{private String name;private String sex;private int age;public User(String name, String sex, int age) {super(); = name;this.sex = sex;this.age = age;}public String getName() {return name;}public void setName(String name) { = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}}UserBookDatepackage code;import java.util.ArrayList;import java.util.List;/*** @author ztr* @version创建时间:2021年3⽉6⽇下午2:07:20* 类说明*/public class UserBookDate {static List<Book> userdateBooks = new ArrayList<Book>(); }Testpackage code;/*** @author ztr* @version创建时间:2021年3⽉6⽇下午4:47:25* 类说明*/public class Test {public static void main(String[] args){Menu menuone = new Menu();menuone.menu();}}Fileiopackage FileIo;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.util.Iterator;import code.Book;import code.LibraryBookDate;/*** @author ztr* @version创建时间:2021年3⽉6⽇下午9:29:18 类说明*/public class Fileio {public void fileread() {// 创建字符缓冲流对象BufferedReader br = null;try {br = new BufferedReader(new FileReader("src/book.txt")); String line;while ((line = br.readLine()) != null) {// 把读取到的字符串数据存储到集合中String[] strArray = line.split(" ");String name = strArray[0];String author = strArray[1];double price = Double.parseDouble(strArray[2]);String type = strArray[3];// 创建书本对象Book book = new Book(name, author, price, type);LibraryBookDate.LibraryBookDate.add(book);}} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// 写⽂件是会有IO异常// TODO: handle exceptione.printStackTrace();} finally {// 为了保障close⼀定执⾏if (br != null) {try {br.close();} catch (IOException e) {e.printStackTrace();}}}}public void filewrite() {// 创建输出缓冲流对象BufferedWriter bw = null;try {bw = new BufferedWriter(new FileWriter("src/book.txt"));// 遍历集合Iterator<Book> iterator = LibraryBookDate.LibraryBookDate .iterator();while (iterator.hasNext()) {Book book = (Book) iterator.next();bw.write(book.getName() + " ");bw.write(book.getAuthor() + " ");bw.write(String.valueOf(book.getPrice()) + " ");bw.write(book.getType() + " ");bw.newLine();// 强制数据输出bw.flush();}} catch (FileNotFoundException e) {// TODO: handle exception} catch (IOException e) {e.printStackTrace();// TODO: handle exception} finally {if (bw != null) {try {bw.close();} catch (IOException e2) {// TODO: handle exceptione2.printStackTrace();}}}}}功能⾮常简单,但可以⾃⼰进⾏功能的扩展。

用java做的一个图书管理系统的源代码

用java做的一个图书管理系统的源代码

用java做的一个图书管理系统的源代码import java.sql.*;import java.util.*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner(System.in);System.out.println("请输入用户名:");String username2=scanner.next();System.out.println("请输入密码:");String password2=scanner.next();if(!(username2.equals("")||password2.equals(""))){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn=DriverManager.getConnection("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=conn.createStatement();rs=stmt.executeQuery(sql);if(rs.next()){if(rs.getString("password").equals(password2)){System.out.println("*********欢迎来山东科技大学图书馆管理系统********");while(true){System.out.println(" 1.图书信息");System.out.println(" 2.读者信息");System.out.println(" 3.管理员信息");System.out.println(" 4.借阅信息");System.out.println(" 5.还书信息");System.out.println(" 6.逾期罚款或损坏赔偿信息");//System.out.println(" 7.退出");System.out.println(" 请输入选择功能的序号:");int a=scanner.nextInt();switch(a){case 1:System.out.println(" 图书信息: ");System.out.println(" 1. 查询图书信息: ");System.out.println(" 2. 插入图书信息: ");System.out.println(" 3. 删除图书信息: ");System.out.println(" 4. 修改图书信息: ");int a1=scanner.nextInt();switch(a1){case 1:System.out.println(" 欢迎进入图书信息查询系统: ");System.out.println(" 1. 无条件查询图书信息: ");System.out.println(" 2. 条件查询图书信息: ");int d=scanner.nextInt();switch(d){case 1:int llll=0;//int mm=0;while(llll!=1){System.out.println(" 1. 无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql0);while(rs.next()){String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){llll=1;System.out.println();};}break;//break;case 2:System.out.println(" 2. 条件查询图书信息: ");System.out.println(" 1. 单条件查询图书信息: ");System.out.println(" 2. 模糊条件查询图书信息: ");System.out.println(" 3. 多表连接查询图书信息: ");System.out.println(" 4. 嵌套查询图书信息: ");System.out.println(" 5. 谓词演算查询");int c12=scanner.nextInt();switch(c12){case 1:System.out.println(" 1.单条件查询: ");System.out.println(" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){System.out.println("请输入图书编码号:");String A=scanner.next();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= stmt.executeQuery(sql1);int x=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续按姓名查询?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};};}break;case 2:System.out.println(" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){System.out.println("请用户输入图书名字中的模糊关键字");String E=scanner.next();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= stmt.executeQuery(sq123);int z=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){dc=1;System.out.println();// break;};}}break;case 3:System.out.println(" 3.多表连接查询查询图书信息: ");int dq=0;while(dq!=1){System.out.println("查询逾期罚款或是赔偿表中的读者的相关信息");System.out.println("请输入逾期罚款或是赔偿的读者编码号");String F=scanner.next();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE fine.bookID=borrowbook.bookID AND borrowbook.reaID=systemreader.reaID AND fine.bookID='"+F+"' ";rs= stmt.executeQuery(sq1234);int n=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};}}break;case 4:System.out.println(" 4.嵌套查询图书信息: ");int dq1=0;System.out.println("查询某读者所在年级女读者的相关信息");System.out.println("请输入某读者的读者编号");String G=scanner.next();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= stmt.executeQuery(sq12345);int m=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入读者编号?yes/no no 返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;System.out.println(" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){System.out.println("查询借阅了某本书的读者的相关信息");System.out.println("请输入该书的名字");String H=scanner.next();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= stmt.executeQuery(sq123456);int l=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;}//c12break;}break;/*case 1:System.out.println(" 1. 查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql);while(rs.next()){//String str =scanner.next();String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}break;*/case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书信息: ");System.out.println("请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;//int mm=0;while(ll!=1){System.out.println(" 3. 删除图书信息: ");System.out.println("请输入要删除的图书编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改图书信息: ");System.out.println("请输入修改的图书ID ");String S=scanner.next();String sql1="SELECT * FROM systembook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这本书,请重新输入");}else{System.out.println("要将书名改为");String bbb=scanner.next();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql1); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/* String updateSql="UPDATE systembook SET bookCopy='"+c1+"' WHERE bookName='数据库管理'";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}break;}break;*/case 2:System.out.println(" 读者信息: ");System.out.println(" 1. 查询读者信息: ");System.out.println(" 2. 插入读者信息: ");System.out.println(" 3. 删除读者信息: ");System.out.println(" 4. 修改读者信息: " );int b1=scanner.nextInt();switch(b1){case 1:System.out.println(" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= stmt.executeQuery(ssql);while(rs.next()){//String str =scanner.next();String reaID=rs.getString(1);String reaName =rs.getString(2);String reaLBID =rs.getString(3);String reaNo =rs.getString(4);String reaSex =rs.getString(5);String reaType =rs.getString(6);String reaDep =rs.getString(7);String reaGrade =rs.getString(8);String reaPre =rs.getString(9);String reaDate =rs.getString(10);System.out.println(reaID+","+reaName+","+reaNo+","+reaSex+","+reaLBID+","+reaType+","+reaD ep+","+reaGrade+","+reaPre+","+reaDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入读者信息: ");System.out.println("请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=scanner.next();String []splitst=str.split(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTO systemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"' ,'"+b20+"')";int n=stmt.executeUpdate(insertSql); //返回记录影响的条数if(n!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除读者信息: ");System.out.println("请输入要删除的读者证号:");String Str=scanner.next();String []Splitst=Str.split(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);String g22 =rs.getString(7);String h22 =rs.getString(8);String i22 =rs.getString(9);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){System.out.println( "没有这个读者,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int m=stmt.executeUpdate(deleSql); //返回记录影响的条数if(m!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改读者信息: ");System.out.println("请输入修改以后的读者的ID ");String S=scanner.next();// String []Ssplitst=S.split(",");//String tt=Ssplitst[0];String sql1="SELECT * FROM systemreader where reaID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);String g222 =rs.getString(7);String h222 =rs.getString(8);String i222 =rs.getString(9);String j222 =rs.getString(10);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222+","+g222+","+h222+", "+i222+","+j222);lll++;}if(lll==0){System.out.println( "没有这个人,请重新输入");}else{System.out.println("要将名字改为");String bb=scanner.next();String updateSql="UPDATE systemreader SET reaName='"+bb+"' WHERE reaID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;/* String updateSql="UPDATE systemreader SET reaSex='"+tt+"' WHERE reaID='20030101'";int l=stmt.executeUpdate(updateSql); //返回记录影响的条数if(l!=0){System.out.println("修改成功!");}break;*/}break;case 3:System.out.println(" 管理员信息: ");System.out.println(" 1. 查询管理员信息: ");System.out.println(" 2. 插入管理员信息: ");System.out.println(" 3. 删除管理员信息: ");System.out.println(" 4. 修改管理员信息: ");System.out.println(" 5. 返回上一级");int c11=scanner.nextInt();switch(c11){case 1:System.out.println(" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= stmt.executeQuery(Ssql);while(rs.next()){// String str =scanner.next();String mID =rs.getString(1);String mName=rs.getString(2);String mSex =rs.getString(3);System.out.println(mID+","+mName+","+mSex);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入管理员信息: ");System.out.println("请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTO manager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除管理员信息: ");System.out.println("请输入要删除的管理员编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这个管理员,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM manager WHERE mID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE mID FROM manager WHERE mID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改管理员信息: ");System.out.println("请输入要修改的管理员编号:");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这个管理员,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将它改为");String bb=scanner.next();String updateSql="UPDATE manager SET mName='"+bb+"' WHERE mID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/*String updateSql="UPDATE manager SET mSex='"+c1+"' WHERE mID=1";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}}break;*/case 4:System.out.println(" 图书借阅信息: ");System.out.println(" 1. 查询图书借阅信息信息: ");System.out.println(" 2. 插入图书借阅信息: ");System.out.println(" 3. 删除图书借阅信息: ");System.out.println(" 4. 修改图书借阅信息: ");System.out.println(" 5. 返回上一级");int d=scanner.nextInt();switch(d){case 1:System.out.println(" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= stmt.executeQuery(Sql4);while(rs.next()){String bookID =rs.getString(1);String reaID =rs.getString(2);String outDate =rs.getString(3);String yhDate =rs.getString(4);System.out.println(bookID+","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书借阅信息: ");System.out.println("请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];//String a15=splitst[4];//String a16=splitst[5];String insertSql="INSERT INTO borrowbook(bookID,reaID,outDate,yhDate) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"')";int ii=stmt.executeUpdate(insertSql); //返回记录影响的条数if(ii!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除图书借阅信息: ");System.out.println("请输入要删除的图书条码号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);// String e22 =rs.getString(5);//String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM borrowbook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};}}}/* String deleSql= "DELETE bookID FROM borrowbook WHERE bookID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1)System.out.println(" 4. 修改借阅读书信息: ");System.out.println("请输入要修改的图书的ID ");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);//String e222 =rs.getString(5);//String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222);lll++;}if(lll==0){System.out.println( "没有这条记录,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将借阅日期改为");String bb=scanner.next();String updateSql="UPDATE borrowbook SET outDate='"+bb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}break;}break;。

Java编写的简单图书管理系统

Java编写的简单图书管理系统

Java编写的简单图书管理系统主界面代码实现package Library;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;public class Login extends JFrame {private static final long serialVersionUID = 1L; private JLabel jlUsername;private JLabel jlPwd;private JTextField txtUsername; //用户名private JTextField txtPassword; //密码private JButton jbOk;private JButton jbCancel;public JLabel getJlUsername() {if(jlUsername==null){jlUsername=new JLabel("账号");jlUsername.setForeground(Color.BLACK);jlUsername.setBounds(118, 40, 85, 30);}return jlUsername;}public JLabel getJlPwd() {if(jlPwd==null){jlPwd=new JLabel("密码");jlPwd.setForeground(Color.BLACK);jlPwd.setBounds(118, 100, 85, 30);}return jlPwd;}public JTextField getTxtUsername() {if(txtUsername==null){txtUsername=new JTextField(20);txtUsername.setBounds(180,40 , 200, 30);}return txtUsername;}public JTextField getTxtPassword() {if(txtPassword==null){txtPassword=new JPasswordField(20);txtPassword.setBounds(180, 100, 200, 30);}return txtPassword;}public JButton getJbOk() {if(jbOk==null){jbOk=new JButton("登陆");jbOk.setBounds(150, 180, 90, 30);//jbOk.addActionListener(this);}return jbOk;}public JButton getJbCancel() {if(jbCancel==null){jbCancel=new JButton("取消");jbCancel.setBounds(300, 180, 90, 30);}return jbCancel;}public Login(String title){super(title);//JFrame frame=new JFrame();Container cantainer=this.getContentPane();this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ImageIcon img= new ImageIcon("F:\\Java\\传习\\src\\Library\\ZF`XY`H48I_}U)C4~}M2~C4.jpg");//这是背景图片JLabel imgLabel = new JLabel(img);//将背景图放在标签里。

基于java的图书管理系统源代码

基于java的图书管理系统源代码

声明:本系统是基于C/S的图书管理系统,主要使用的是Oracle数据库,下面附所有实现代码package library;import class book_add extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2;JLabel book_id_label,book_name_label,author_label,press_label,press_date_label,price_label,book_num_label,borrowed_num_label,addr ess;JTextField book_id_TextField,book_name_TextField,author_TextField,press_TextField,press_date_TextField,price_TextField,book_num_TextField,borrowed_count;JComboBox addresst;Container c;JButton clear,add,exit;public book_add(){super("添加图书信息");c=getContentPane();(new BorderLayout());book_id_label=new JLabel("编号",;book_name_label=new JLabel("名称",; author_label=new JLabel("作者",;press_label=new JLabel("出版社",;press_date_label=new JLabel("出版日期",; price_label=new JLabel("价格",;book_num_label=new JLabel("库存数",; borrowed_num_label=new JLabel("已借阅数",; address=new JLabel("藏书地址",;book_id_TextField=new JTextField(15); book_name_TextField=new JTextField(15); author_TextField=new JTextField(15); press_TextField=new JTextField(15);press_date_TextField=new JTextField(15); price_TextField=new JTextField(15);book_num_TextField=new JTextField(15); borrowed_count=new JTextField(15); ("0");addresst=new JComboBox();("扬子津图书馆");("荷花池图书馆");("瘦西湖图书馆"); ("淮海路图书馆"); panel1=new JPanel(); (new GridLayout(9,2)); (book_id_label); (book_id_TextField); (book_name_label); (book_name_TextField); (press_label);(press_TextField); (author_label); (author_TextField); (press_date_label); (press_date_TextField); (price_label);(price_TextField); (book_num_label); (book_num_TextField); (borrowed_num_label); (borrowed_count); (address); (addresst);panel2=new JPanel();(new GridLayout(1,3));clear=new JButton("清空");(this);add=new JButton("添加");(this);exit=new JButton("退出");(this);(clear);(add);(exit);(panel1,;(panel2,;setVisible(true);}public void actionPerformed(ActionEvent e) {if()==exit){();}else if()==clear){("");("");("");("");("");("");("");}else if()==add){if().trim().equals("")){(null, "书号不能为空");}else if().trim().equals("")){(null, "书名不能为空");}else if().trim().equals("")){(null, "作者不能为空");}else if().trim().equals("")){(null, "出版社不能为空"); }else if().trim().equals("")){(null, "出版日期不能为空"); }else if().trim().equals("")){(null, "价格不能为空");}else if().trim().equals("")){(null, "库存不能为空");}else if().trim().equals("")){(null, "借阅数不能为空"); }else {try{String strSQL="insert into book(book_id,book_name,press,author,press_date,price,book_count,borrowed_count,st ore_address) values('"+().trim()+"','"+().trim()+"','"+().trim()+"','"+().trim()+"','"+().trim()+"','"+().trim()+"','"+().trim()+"','"+().trim()+"','"+()+"')";if(strSQL)){();(null,"添加图书成功");}else{(null,"添加图书失败");();}();}catch(Exception ex){}}}}}package library;import .*;import .*;import class book_delete extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;Container c;JLabel TipLabel=new JLabel("请选择要删除的书名",;JComboBox bb=new JComboBox();JButton yes,exit;JPanel panel1=new JPanel();public book_delete(){super("删除图书信息");c=getContentPane();(new BorderLayout());try{String strSQL="select book_name from book where book_count>borrowed_count";rs=(strSQL);while()){(1));}}catch(SQLException sqle){}catch(Exception ex){}(TipLabel,;(bb,;yes=new JButton("确定");exit=new JButton("退出");(this);(this);(yes);(exit);(panel1,;setVisible(true);}public void actionPerformed(ActionEvent e) {if()==exit){();}else if()==yes){try{String strSQL="select borrowed_count from book where book_name='"+()+"'";rs=(strSQL);if(!()){(null,"书库里没有你要删除的书");}else{String strSql="delete from book where book_name='"+()+"'and borrowed_count=0";();int count=(1);if(!(count==0)){(null,"此书还有学生没有还,不可删除");}else if(strSql)){(null,"删除成功");();();}else{(null,"删除失败");();();}}}catch(SQLException sqle){}catch(Exception ex){}}}}package library;import class book_modify extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2,panel3;JLabel TipLabel=new JLabel("输入书名点确定,将调出此书的相关信息");JLabel book_name_label,author_label,press_label,press_date_label,price_label;JTextField book_name_TextField,author_TextField,press_TextField,press_date_TextField,price_TextField;Container c;JButton clear,yes,update,exit;public book_modify(){super("修改图书信息");c=getContentPane();(new BorderLayout());panel3=new JPanel();(TipLabel);(panel3,;book_name_label=new JLabel("名称",; author_label=new JLabel("作者",;press_label=new JLabel("出版社",;press_date_label=new JLabel("出版日期",; price_label=new JLabel("价格",;book_name_TextField=new JTextField(15); author_TextField=new JTextField(15); press_TextField=new JTextField(15); press_date_TextField=new JTextField(15); price_TextField=new JTextField(15); panel1=new JPanel();(new GridLayout(6,2));(book_name_label);(book_name_TextField);(author_label);(author_TextField);(press_label);(press_TextField);(press_date_label);(press_date_TextField);(price_label);(price_TextField);panel2=new JPanel();(new GridLayout(1,4));clear=new JButton("清空");yes=new JButton("确定");update=new JButton("更新");exit=new JButton("退出");(clear);(yes);(update);(exit);(this);(this);(this);(this);(false);(panel1,;(panel2,;setVisible(true);}public void actionPerformed(ActionEvent e) {if()==exit){();;}else if()==clear){("");("");("");("");("");}else if()==yes){try{String strSQL="select * from book where book_name='"+().trim()+"'";rs=(strSQL);while()){("book_name"));("author"));("press"));("press_date"));("price"));}(true);}catch(NullPointerException upe){}catch(Exception es){}}else if()==update){try{String strSQL="update book set book_name='"+().trim()+"',press='"+().trim()+"',author='"+().trim()+"',press_date='"+().trim()+"',price='"+().trim()+"' where book_name='"+().trim()+"'";if(strSQL)){();(null,"更新图书成功");}else {(null,"更新图书失败");}();}catch(Exception sqle){}}}}package library;import class bookborrow extends JFrame implements ActionListener{DataBaseManager db=new DataBaseManager();ResultSet rs;Container c;JPanel panel1,panel2;JLabel borrowname,bookname,borrowdate,returndate,is_return_label;JTextField borrowdateField,returndateField,is_return;JButton clear,yes,cancel;JComboBox borrownameBox=new JComboBox();JComboBox booknameBox=new JComboBox();public bookborrow(){super("书籍出借");c=getContentPane();(new BorderLayout());Calendar cal = ();int year,month,day;quals("")){(null, "对不起,没有读者借阅");}else if().equals("")){(null, "对不起,现在书库没有书");}else {try{rim();SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");Date dateStart=(startDate);Calendar cd=();(dateStart);, 2);String returnDate=());String strSQL="insert into borrow(student_name,book_name,borrow_date,return_date,is_returned) values('"+()+"','"+()+"','"+().trim()+"','"+returnDate+"','"+().trim()+"')";if(strSQL)){(null, "借阅完成");strSQL = "update reader set borrow_count=borrow_count+1 where student_name='"+()+"'";(strSQL);strSQL="update book set borrowed_count=borrowed_count+1 where book_name='"+()+"'";(strSQL);();();}else{(null, "借阅失败");();();}}catch(Exception se){} }}}}package library;import .*;import .*;import class bookborrowlist extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;Container c;JPanel panel1,panel2;JLabel bookname,studentname;JTextField booknamet,studentnamet;JButton search,exit;JTable table=null;DefaultTableModel defaultModel=null;public bookborrowlist(){super("借阅列表");c=getContentPane();(new BorderLayout());bookname=new JLabel("书名",;studentname=new JLabel("人名",;booknamet=new JTextField(15);studentnamet=new JTextField(15);search=new JButton("查询");exit=new JButton("退出");(this);(this);Box box1=();(studentname);(studentnamet);(search);Box box2=();(bookname);(booknamet);(exit);Box boxH=();(box1);(box2);());panel1=new JPanel();(boxH);panel2=new JPanel();String []name={"读者","书名","借阅时间","应还时间","是否归还"};String [][]data=new String[0][0];defaultModel=new DefaultTableModel(data,name);table=new JTable(defaultModel);(new Dimension(400,80));JScrollPane s=new JScrollPane(table);(s);(panel1,;(panel2,;}public void actionPerformed(ActionEvent e){if()==exit){();();}else if()==search){String strSQL="select student_name,book_name,borrow_date,return_date,is_returned from borrow";String strSql=null;if().trim().equals("")&&().trim().equals("")){strSql=strSQL;}else if().trim().equals("")){strSql="selectstudent_name,book_name,borrow_date,return_date,is_returned from borrow where book_name='"+().trim()+"'";}else if().trim().equals("")){strSql="selectstudent_name,book_name,borrow_date,return_date,is_returned from borrow where student_name='"+().trim()+"'";}else{strSql="selectstudent_name,book_name,borrow_date,return_date,is_returned from borrow where student_name='"+().trim()+"'and book_name='"+().trim()+"'";(null, "你借的书还还有7天超期"); }try{int rowCount=()-1;int j=rowCount;for(int i=0;i<=rowCount;i++){(j);(j);j=j-1;}rs=(strSql);while()){Vector insertRow=new Vector();(1));(2));(3));(4));(5));(insertRow);}();}catch(SQLException sqle){}catch(Exception ex){}}}}package library;import .*;import .*;import class bookborrowModify extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2,panel3;Container c;JLabel tiplabel=new JLabel("输入借阅者姓名和书名单击确定,将调出此书的相关信息");JLabel borrowlabel,namelabel,borrowdate;JTextField borrowField,nameField,dateField;JButton clear,yes,update,cancel;public bookborrowModify(){super("修改图书出借信息");c=getContentPane();(new BorderLayout());panel3=new JPanel();(tiplabel);(panel3,;borrowlabel=new JLabel("借阅者姓名",;namelabel=new JLabel("书名",;borrowdate=new JLabel("借书日期",;borrowField=new JTextField(15);nameField=new JTextField(15);dateField=new JTextField(15);panel1=new JPanel();(new GridLayout(3,2));(borrowlabel); (borrowField); (namelabel); (nameField); (borrowdate); (dateField);(panel1,;panel2=new JPanel(); (new GridLayout(1,4)); clear=new JButton("清空"); yes=new JButton("确定"); update=new JButton("更新"); cancel=new JButton("取消"); (this);(this);(this);(this);(clear);(yes);(update);(cancel);(panel2,;setVisible(true);setSize(400,200);}public void actionPerformed(ActionEvent e){if()==clear){("");("");("");}else if()==cancel){();}else if()==yes){try{String strSQL="select student_name,book_name,borrow_date from borrow where student_name='"+().trim()+"'and book_name='"+().trim()+"'";rs=(strSQL);if(!()){(null,"此学生没有借过书或者没有此书");}else{(1));(2));(3));(true);}}catch(Exception ex){}}else if()==update){String strSQL="update borrow set borrow_date='"+().trim()+"' where student_name='"+().trim()+"'and book_name='"+().trim()+"'";if(strSQL)){(null,"更新成功");();();}else{(null,"更新失败");();();}}}}package library;import .*;import .*;import class booklist extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;Container c;JPanel panel1,panel2,panel3;JLabel bookname,authorname,press; JTextField booknamet,authornamet,presst; JButton search,exit;JTable table=null; DefaultTableModel defaultModel=null; public booklist(){super("书籍信息查询");c=getContentPane();(new BorderLayout());bookname=new JLabel("书名",;authorname=new JLabel("作者",;press=new JLabel("出版社",;booknamet=new JTextField(15);authornamet=new JTextField(15);presst=new JTextField(15);search=new JButton("查询");exit=new JButton("退出");(this);(this);panel1=new JPanel();(bookname);(booknamet);(authorname);(authornamet);panel2=new JPanel();(press);(presst);(search);(exit);String []name={"书号","书名","出版社","作者","出版日期","价格","图书数目","已借数目","剩余数目","藏书地址"};String [][]data=new String[0][0];defaultModel=new DefaultTableModel(data,name);table=new JTable(defaultModel);(new Dimension(400,80));JScrollPane s=new JScrollPane(table);panel3=new JPanel();(s);(panel1,;(panel2,;(panel3,;}public void actionPerformed(ActionEvent e){if()==exit){();();}else if()==search){String strSQL="select book_id,book_name,press,author,press_date,price,book_count,borrowed_count,book_c ount-borrowed_count,store_address from book";String strSql=null;if().trim().equals("")&&().trim().equals("")&&().trim().equals("")){strSql=strSQL;}else if().trim().equals("")&&().trim().equals("")){strSql="selectbook_id,book_name,press,author,press_date,price,book_count,borrowed_count,book_c ount-borrowed_count,store_address from book where press='"+().trim()+"'";}else if().trim().equals("")&&().trim().equals("")){strSql="selectbook_id,book_name,press,author,press_date,price,book_count,borrowed_count,book_c ount-borrowed_count,store_address from book where book_name='"+().trim()+"'";}else if().trim().equals("")&&().trim().equals("")){strSql="selectbook_id,book_name,press,author,press_date,price,book_count,borrowed_count,book_c ount-borrowed_count,store_address from book where author='"+().trim()+"'";}else{strSql="selectbook_id,book_name,press,author,press_date,price,book_count,borrowed_count,book_c ount-borrowed_count,store_address from book where book_name='"+().trim()+"'and author='"+().trim()+"'and press='"+().trim()+"'";}try{int rowCount=()-1;int j=rowCount;for(int i=0;i<=rowCount;i++){(j);(j);j=j-1;}rs=(strSql);while()){Vector insertRow=new Vector();(1));(2));(3));(4));(5));(6));(7));(8));(9));(10));(insertRow);}();}catch(SQLException sqle){}catch(Exception ex){}}}}package library;import .*;import .*;import class bookreturn extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2;Container c;JLabel namelabel,booklabel,returndatelabel;JTextField returnField;JButton clear,yes,cancel;JComboBox bookname=new JComboBox();JComboBox readername=new JComboBox();public bookreturn(){super("图书还入");c=getContentPane();(new BorderLayout());Calendar cal = ();sdf = new SimpleDateFormat("yyyy-MM-dd");String cdate = ());namelabel=new JLabel("还书者姓名",;booklabel =new JLabel("书名",;returndatelabel=new JLabel("日期",;returnField=new JTextField(15);(cdate);try{String s="";String strSQL="select student_name from reader where borrow_count!=0";rs=(strSQL);while()){(1));}}catch(SQLException sqle){}catch(Exception ex){}try{String s="";String strSQL="select book_name from borrow where is_returned='否'";rs=(strSQL);while()){(1));}}catch(SQLException sqle){}catch(Exception ex){}panel1=new JPanel();(new GridLayout(3,2)); (namelabel);(readername);(booklabel);(bookname);(returndatelabel);(returnField);(panel1,;panel2=new JPanel();(new GridLayout(1,3));clear=new JButton("清除");yes=new JButton("确定");cancel=new JButton("取消"); (this);(this);(this);(clear);(yes);(cancel);(panel2,;setVisible(true);setSize(300,200);}public void actionPerformed(ActionEvent e) {if()==cancel){();}else if()==clear){("");}else if()==yes){if().equals("")){(null,"没有读者借书");}else if().equals("")){(null,"图书馆没有借过书");}else{try{String strSQL="update borrow set act_returned ='"+().trim()+"',is_returned='是' where student_name='"+()+"' and book_name='"+()+"'";if(strSQL)){(null,"还书完成");strSQL="update reader set borrow_count=borrow_count-1 where student_name='"+()+"'";(strSQL);strSQL="update book set borrowed_count=borrowed_count-1 where book_name='"+()+"'";(strSQL);();();}else{(null,"还书失败");();();}}catch(Exception se){}};import .*;import class bookreturnModify extends JFrame implements ActionListener{ DataBaseManager db=new DataBaseManager();ResultSet rs;JPanel panel1,panel2,panel3;Container c;JLabel tiplabel=new JLabel("输入还书者姓名和书名单击确定,将调出此书的相关信息");JLabel borrowlabel,namelabel,borrowdate;JTextField borrowField,nameField,dateField;JButton clear,yes,update,cancel;public bookreturnModify(){super("修改图书还入信息");c=getContentPane();(new BorderLayout());panel3=new JPanel();(tiplabel);(panel3,;borrowlabel=new JLabel("还书者姓名",;namelabel=new JLabel("书名",;borrowdate=new JLabel("还书日期",;borrowField=new JTextField(15);nameField=new JTextField(15);dateField=new JTextField(15);panel1=new JPanel();(new GridLayout(3,2));(borrowlabel);(borrowField);(namelabel);(nameField);(borrowdate);(dateField);(panel1,;panel2=new JPanel();(new GridLayout(1,4));clear=new JButton("清空");yes=new JButton("确定");update=new JButton("更新");cancel=new JButton("取消");(this);(this);(this);(this);(clear);(yes);(update);(cancel);(panel2,;setVisible(true);setSize(400,200);}public void actionPerformed(ActionEvent e) {if()==clear){("");("");("");}else if()==cancel){();}else if()==yes){try{String strSQL="select student_name,book_name,act_returned from borrow where student_name='"+().trim()+"'and book_name='"+().trim()+"'";rs=(strSQL);if(!()){(null,"此学生没有借过书");}else{(1));(2));(3));(true);}}catch(Exception ex){}}else if()==update){String strSQL="update borrow set return_date='"+().trim()+"' where student_name='"+().trim()+"'and book_name='"+().trim()+"'";if(strSQL)){(null,"更新成功");();();}else{(null,"更新失败");();();}}}}package library;import .*;import .*;import class MainWindow extends JFrame implements ActionListener{ JPanel panel1;Container c;JMenuBar MenuB;JMenu system,book,borrow,retu,info,usermag;JMenu student;quals("系统管理员")){(true);(true);(true);(true);(true);(true);(true);}else if().equals("书籍管理员")) {(false);(true);(false);(false);(true);(false);(true);}else if().equals("借阅管理员")) {(false);(false);。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

用java做的一个图书管理系统的源代码import java.sql.*;import java.util.*;public class T{public static void main(String[] args) throws Exception{Connection conn=null;Statement stmt=null;ResultSet rs=null;while(true){Scanner scanner=new Scanner(System.in);System.out.println("请输入用户名:");String username2=scanner.next();System.out.println("请输入密码:");String password2=scanner.next();if(!(username2.equals("")||password2.equals(""))){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn=DriverManager.getConnection("jdbc:odbc:book","","");String sql="select * from ww where username='"+username2+"'";stmt=conn.createStatement();rs=stmt.executeQuery(sql);if(rs.next()){if(rs.getString("password").equals(password2)){System.out.println("*********欢迎来山东科技大学图书馆管理系统********");while(true){System.out.println(" 1.图书信息");System.out.println(" 2.读者信息");System.out.println(" 3.管理员信息");System.out.println(" 4.借阅信息");System.out.println(" 5.还书信息");System.out.println(" 6.逾期罚款或损坏赔偿信息");//System.out.println(" 7.退出");System.out.println(" 请输入选择功能的序号:");int a=scanner.nextInt();switch(a){case 1:System.out.println(" 图书信息: ");System.out.println(" 1. 查询图书信息: ");System.out.println(" 2. 插入图书信息: ");System.out.println(" 3. 删除图书信息: ");System.out.println(" 4. 修改图书信息: ");int a1=scanner.nextInt();switch(a1){case 1:System.out.println(" 欢迎进入图书信息查询系统: ");System.out.println(" 1. 无条件查询图书信息: ");System.out.println(" 2. 条件查询图书信息: ");int d=scanner.nextInt();switch(d){case 1:int llll=0;//int mm=0;while(llll!=1){System.out.println(" 1. 无条件查询图书信息: ");String Sql0 = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql0);while(rs.next()){String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){llll=1;System.out.println();};}break;//break;case 2:System.out.println(" 2. 条件查询图书信息: ");System.out.println(" 1. 单条件查询图书信息: ");System.out.println(" 2. 模糊条件查询图书信息: ");System.out.println(" 3. 多表连接查询图书信息: ");System.out.println(" 4. 嵌套查询图书信息: ");System.out.println(" 5. 谓词演算查询");int c12=scanner.nextInt();switch(c12){case 1:System.out.println(" 1.单条件查询: ");System.out.println(" 1.按图书名编码号查询图书信息: ");int ddd=0;while(ddd!=1){System.out.println("请输入图书编码号:");String A=scanner.next();String sql1= "SELECT * FROM systembook WHERE bookID ='"+A+"' ";rs= stmt.executeQuery(sql1);int x=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);x++;}if(x==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续按姓名查询?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};};}break;case 2:System.out.println(" 2.模糊查询图书信息: ");int dc=0;while(dc!=1){System.out.println("请用户输入图书名字中的模糊关键字");String E=scanner.next();String sq123= "SELECT * FROM systembook WHERE bookName LIKE'"+E+"%'";rs= stmt.executeQuery(sq123);int z=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);z++;}if(z==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){dc=1;System.out.println();// break;};}}break;case 3:System.out.println(" 3.多表连接查询查询图书信息: ");int dq=0;while(dq!=1){System.out.println("查询逾期罚款或是赔偿表中的读者的相关信息");System.out.println("请输入逾期罚款或是赔偿的读者编码号");String F=scanner.next();String sq1234= "SELECT * FROM fine,borrowbook,systemreader WHERE fine.bookID=borrowbook.bookID AND borrowbook.reaID=systemreader.reaID AND fine.bookID='"+F+"' ";rs= stmt.executeQuery(sq1234);int n=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);n++;}if(n==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字中的模糊关键字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){ddd=1;System.out.println();};}}break;case 4:System.out.println(" 4.嵌套查询图书信息: ");int dq1=0;System.out.println("查询某读者所在年级女读者的相关信息");System.out.println("请输入某读者的读者编号");String G=scanner.next();String sq12345= "SELECT * FROM systemreader WHERE reaGrade=(SELECT reaGrade FROM systemreader WHERE reaID='"+G+"') AND reasex='女'";rs= stmt.executeQuery(sq12345);int m=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);m++;}if(m==0){System.out.println("查无此书,请重新输入");}else{System.out.println("是否继续输入读者编号?yes/no no 返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;System.out.println(" 5. 谓词演算查询:");int dq1123=0;while(dq1123!=1){System.out.println("查询借阅了某本书的读者的相关信息");System.out.println("请输入该书的名字");String H=scanner.next();String sq123456= "SELECT * FROM systemreader WHERE reaID IN (SELECT reaID FROM borrowbook WHERE bookName='"+H+"')";rs= stmt.executeQuery(sq123456);int l=0;while(rs.next()){String a2 =rs.getString(1);String b2 =rs.getString(2);String c2 =rs.getString(3);String d2 =rs.getString(4);String e2 =rs.getString(5);System.out.println(a2+","+b2+" ,"+c2+","+d2+","+e2);l++;}if(l==0){System.out.println("查无此人,请重新输入");}else{System.out.println("是否继续输入图书名字?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){d=1;System.out.println();};}}break;}//c12break;}break;/*case 1:System.out.println(" 1. 查询图书信息: ");String Sql = "SELECT * FROM systembook ";rs= stmt.executeQuery(Sql);while(rs.next()){//String str =scanner.next();String bookID =rs.getString(1);String bookNo =rs.getString(2);String bookName =rs.getString(3);String bookWriter =rs.getString(4);String bookPub =rs.getString(5);System.out.println(bookID+","+bookNo+","+bookName+","+ bookWriter+","+bookPub);}break;*/case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书信息: ");System.out.println("请按顺序插入图书条码号,图书索书号,图书名字,图书作者,图书出版社");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String insertSql="INSERT INTO systembook(bookID,bookNo,bookName,bookWriter,bookPub)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;//int mm=0;while(ll!=1){System.out.println(" 3. 删除图书信息: ");System.out.println("请输入要删除的图书编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM systembook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{{String deleSql= "DELETE FROM systembook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改图书信息: ");System.out.println("请输入修改的图书ID ");String S=scanner.next();String sql1="SELECT * FROM systembook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这本书,请重新输入");}else{System.out.println("要将书名改为");String bbb=scanner.next();String updateSql1="UPDATE systembook SET bookName='"+bbb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql1); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/* String updateSql="UPDATE systembook SET bookCopy='"+c1+"' WHERE bookName='数据库管理'";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}break;}break;*/case 2:System.out.println(" 读者信息: ");System.out.println(" 1. 查询读者信息: ");System.out.println(" 2. 插入读者信息: ");System.out.println(" 3. 删除读者信息: ");System.out.println(" 4. 修改读者信息: " );int b1=scanner.nextInt();switch(b1){case 1:System.out.println(" 1. 查询读者信息: ");String ssql = "SELECT * FROM systemreader ";rs= stmt.executeQuery(ssql);while(rs.next()){//String str =scanner.next();String reaID=rs.getString(1);String reaName =rs.getString(2);String reaLBID =rs.getString(3);String reaNo =rs.getString(4);String reaSex =rs.getString(5);String reaType =rs.getString(6);String reaDep =rs.getString(7);String reaGrade =rs.getString(8);String reaPre =rs.getString(9);String reaDate =rs.getString(10);System.out.println(reaID+","+reaName+","+reaNo+","+reaSex+","+reaLBID+","+reaType+","+reaD ep+","+reaGrade+","+reaPre+","+reaDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入读者信息: ");System.out.println("请按顺序插入借书卡证号读者名字读者学号读者性别读者LBID 读者类型读者学院读者年级读者专业办证日期");String str=scanner.next();String []splitst=str.split(",");String b11=splitst[0];String b12=splitst[1];String b13=splitst[2];String b14=splitst[3];String b15=splitst[4];String b16=splitst[5];String b17=splitst[6];String b18=splitst[7];String b19=splitst[8];String b20=splitst[9];String insertSql="INSERT INTO systemreader(reaID,reaName,reaNo,reaSex,reaLBID,reaType,reaDep,reaGrade,reaPre,reaDate) VALUES('"+b11+"','"+b12+"','"+b13+"','"+b14+"','"+b15+"','"+b16+"','"+b17+"','"+b18+"','"+b19+"' ,'"+b20+"')";int n=stmt.executeUpdate(insertSql); //返回记录影响的条数if(n!=0){System.out.println("插入成功!"); }System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除读者信息: ");System.out.println("请输入要删除的读者证号:");String Str=scanner.next();String []Splitst=Str.split(",");String r=Splitst[0];String sql1="SELECT * FROM systemreader where reaID='"+r+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);String g22 =rs.getString(7);String h22 =rs.getString(8);String i22 =rs.getString(9);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22+","+g22+","+h22+","+i22);kkk++;}if(kkk==0){System.out.println( "没有这个读者,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE FROM systemreader WHERE reaID='"+r+"'";int m=stmt.executeUpdate(deleSql); //返回记录影响的条数if(m!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改读者信息: ");System.out.println("请输入修改以后的读者的ID ");String S=scanner.next();// String []Ssplitst=S.split(",");//String tt=Ssplitst[0];String sql1="SELECT * FROM systemreader where reaID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);String g222 =rs.getString(7);String h222 =rs.getString(8);String i222 =rs.getString(9);String j222 =rs.getString(10);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222+","+g222+","+h222+", "+i222+","+j222);lll++;}if(lll==0){System.out.println( "没有这个人,请重新输入");}else{System.out.println("要将名字改为");String bb=scanner.next();String updateSql="UPDATE systemreader SET reaName='"+bb+"' WHERE reaID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;/* String updateSql="UPDATE systemreader SET reaSex='"+tt+"' WHERE reaID='20030101'";int l=stmt.executeUpdate(updateSql); //返回记录影响的条数if(l!=0){System.out.println("修改成功!");}break;*/}break;case 3:System.out.println(" 管理员信息: ");System.out.println(" 1. 查询管理员信息: ");System.out.println(" 2. 插入管理员信息: ");System.out.println(" 3. 删除管理员信息: ");System.out.println(" 4. 修改管理员信息: ");System.out.println(" 5. 返回上一级");int c11=scanner.nextInt();switch(c11){case 1:System.out.println(" 1. 查询管理员信息: ");String Ssql = "SELECT * FROM manager ";rs= stmt.executeQuery(Ssql);while(rs.next()){// String str =scanner.next();String mID =rs.getString(1);String mName=rs.getString(2);String mSex =rs.getString(3);System.out.println(mID+","+mName+","+mSex);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入管理员信息: ");System.out.println("请按顺序插入管理员的编号,管理员的姓名,管理员的性别,所管书库,电话,地址");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];String a15=splitst[4];String a16=splitst[5];String insertSql="INSERT INTO manager(mID,mName,mSex,mAuth,mTeleph,mAddre)VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"','"+a15+"','"+a16+"')";int i=stmt.executeUpdate(insertSql); //返回记录影响的条数if(i!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除管理员信息: ");System.out.println("请输入要删除的管理员编号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM manager where mID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);String e22 =rs.getString(5);String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22+","+e22+","+f22);kkk++;}if(kkk==0){System.out.println( "没有这个管理员,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM manager WHERE mID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};};}}/* String deleSql= "DELETE mID FROM manager WHERE mID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1){System.out.println(" 4. 修改管理员信息: ");System.out.println("请输入要修改的管理员编号:");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM manager where mID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);String e222 =rs.getString(5);String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222+","+e222+","+f222);lll++;}if(lll==0){System.out.println( "没有这个管理员,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将它改为");String bb=scanner.next();String updateSql="UPDATE manager SET mName='"+bb+"' WHERE mID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}}break;}break;/*String updateSql="UPDATE manager SET mSex='"+c1+"' WHERE mID=1";int t=stmt.executeUpdate(updateSql); //返回记录影响的条数if(t!=0){System.out.println("修改成功!");}}break;*/case 4:System.out.println(" 图书借阅信息: ");System.out.println(" 1. 查询图书借阅信息信息: ");System.out.println(" 2. 插入图书借阅信息: ");System.out.println(" 3. 删除图书借阅信息: ");System.out.println(" 4. 修改图书借阅信息: ");System.out.println(" 5. 返回上一级");int d=scanner.nextInt();switch(d){case 1:System.out.println(" 1. 查询图书借阅信息: ");String Sql4 = "SELECT * FROM borrowbook ";rs= stmt.executeQuery(Sql4);while(rs.next()){String bookID =rs.getString(1);String reaID =rs.getString(2);String outDate =rs.getString(3);String yhDate =rs.getString(4);System.out.println(bookID+","+reaID+","+outDate+","+yhDate);}break;case 2:int zz=0;while(zz!=1){System.out.println(" 2. 插入图书借阅信息: ");System.out.println("请按顺序插入图书的的编号,读者编号,图书借出日期,图书归还日期");String str=scanner.next();String []splitst=str.split(",");String a11=splitst[0];String a12=splitst[1];String a13=splitst[2];String a14=splitst[3];//String a15=splitst[4];//String a16=splitst[5];String insertSql="INSERT INTO borrowbook(bookID,reaID,outDate,yhDate) VALUES('"+a11+"','"+a12+"','"+a13+"','"+a14+"')";int ii=stmt.executeUpdate(insertSql); //返回记录影响的条数if(ii!=0){System.out.println("插入成功!");}System.out.println("是否继续插入?yes/no no返回主菜单");String k=scanner.next();if(k.startsWith("yes")){System.out.println();};if(k.startsWith("no")){zz=1;System.out.println();};}break;case 3:int ll=0;while(ll!=1){System.out.println(" 3. 删除图书借阅信息: ");System.out.println("请输入要删除的图书条码号:");String Str=scanner.next();String []Splitst=Str.split(",");String b3=Splitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+b3+"'";rs= stmt.executeQuery(sql1);int kkk=0;while(rs.next()){String a22 =rs.getString(1);String b22 =rs.getString(2);String c22 =rs.getString(3);String d22 =rs.getString(4);// String e22 =rs.getString(5);//String f22 =rs.getString(6);System.out.println(a22+","+b22+" ,"+c22+","+d22);kkk++;}if(kkk==0){System.out.println( "没有这本书,请重新输入");}else{//System.out.println( "您是否真的要删除? yes/no");//String k=scanner.next();//if(k.startsWith("y")){String deleSql= "DELETE FROM borrowbook WHERE bookID='"+b3+"'";int p=stmt.executeUpdate(deleSql); //返回记录影响的条数if(p!=0){System.out.println("删除成功!");}System.out.println("是否继续删除?yes/no no返回主菜单");String l=scanner.next();if(l.startsWith("yes")){System.out.println();};if(l.startsWith("no")){ll=1;System.out.println();};}}}/* String deleSql= "DELETE bookID FROM borrowbook WHERE bookID='"+b3+"'";int k=stmt.executeUpdate(deleSql); //返回记录影响的条数if(k!=0){System.out.println("删除成功!");}*/break;case 4:int mm=0;while(mm!=1)System.out.println(" 4. 修改借阅读书信息: ");System.out.println("请输入要修改的图书的ID ");String S=scanner.next();String []Ssplitst=S.split(",");String c1=Ssplitst[0];String sql1="SELECT * FROM borrowbook where bookID='"+S+"'";rs= stmt.executeQuery(sql1);int lll=0;while(rs.next()){String a222 =rs.getString(1);String b222 =rs.getString(2);String c222 =rs.getString(3);String d222 =rs.getString(4);//String e222 =rs.getString(5);//String f222 =rs.getString(6);System.out.println(a222+","+b222+" ,"+c222+","+d222);lll++;}if(lll==0){System.out.println( "没有这条记录,请重新输入");}else{// System.out.println( "要修改的信息");//String aa=scanner.next();System.out.println("要将借阅日期改为");String bb=scanner.next();String updateSql="UPDATE borrowbook SET outDate='"+bb+"' WHERE bookID='"+S+"'";int hh=stmt.executeUpdate(updateSql); //返回记录影响的条数if(hh!=0){System.out.println("修改成功!");}System.out.println("是否继续修改yes/no no返回主菜单");String o=scanner.next();if(o.startsWith("yes")){System.out.println();};if(o.startsWith("no")){mm=1;System.out.println();};}break;}break;。

相关文档
最新文档