【SQL开源代码栏目提醒】:网学会员在SQL开源代码频道为大家收集整理了“Java_项目开发实例_图书信息管理系统开发文档及源码 - 开发文档“提供大家参考,希望对大家有所帮助!
Java 开发实例 源码——图书信息管理系统 图 书 信息管理系统一、 系统 功能概 述: 根据图 书 信息管理系统 的特点,可以将 本系统 分为 2 大功能模块 ,分别为 :基础 数 据维 护 、系统 数 据维 护 。
本系统 各个 部分及其包括的具体功能模块 如下图 所示:二、 数 据库 设 计 :图书信息表:字段名 说明 类型 长度及备注ISBN 国际标准书号 Varchar13 主键typeId 图书类型 id IntBookname 书名 Varchar40Writer 作者 Varchar21Translater 译者 Varchar30 可以为空Publisher 出版社 Varchar50Date 出版日期 SmalldatetimePrice 价格 money图书类别表: 1 Java 开发实例 源码——图书信息管理系统字段名 说明 类型 长度及备注TypeName 图书类型 Varchar20Id 自动编号 Int 主键用户信息表:字段名 说明 类型 长度及备注Id 自动编号 Int 主键Name 姓名 Varchar2Sex 性别 Varchar2Age 年龄 intIdentitycard 证件号码 Varchar2Workdate 办证日期 datetimeTel 电话号码 Varchar2Yajin 押金 IntPassword 密码 Nvarchar10admin 管理员 Nchar10读者信息表:字段名 说明 类型 长度及备注Name 姓名 Varchar10Sex 性别 Varchar2Age 年龄 intidentityCard 证件号码 Varchar30Date 日期 SmalldatetimemanNum 最大书量 IntTel 电话号码 Varchar15keepMoney 押金 MineyZj 证件类型 IntZy 职业 Varchar50ISBN 国际标准书号 Varchar13bztime 办证时间 datetime三、 系统 源
代码 :Com.zhang.dao:Dao.java //数据库的连接与操作类package com.zhang.daoimport java.
sql.Connectionimport java.
sql.Dateimport java.
sql.DriverManagerimport java.
sql.ResultSetimport java.
sql.SQLExceptionimport java.util.ArrayList 2 Java 开发实例 源码——图书信息管理系统import java.util.Listimport com.zhang.model.BookInfoimport com.zhang.model.BookTypeimport com.zhang.model.Operatorimport com.zhang.model.Readerimport com.zhang.model.Userpublic class Dao protected static String dbClassName quotcom.microsoft.sqlserver.jdbc.SQLServerDriverquot protected static String dbUrl quotjdbc:sqlserver://localhost:1433quot quotDatabaseNamedb_libSelectMethodCursorquot protected static String dbUser quotsaquot protected static String dbPwd quotzhangyongquot protected static String second null private static Connection conn null //创建数据库连接 private Dao try if conn null Class.forNamedbClassName.newInstance conn DriverManager.getConnectiondbUrl dbUser dbPwd System.out.printlnquot数据库连接成功!quot else return catch Exception ee ee.printStackTrace //执行查询 private static ResultSet executeQueryString
sql try ifconnnull new Dao returnconn.createStatementResultSet.TYPE_SCROLL_SENSITIVEResultSet.CONCUR_UPDATABLE.executeQuerysql catch SQLException e e.printStackTrace return null finally 3 Java 开发实例 源码——图书信息管理系统 //执行更新 private static int executeUpdateString
sql try ifconnnull new Dao return conn.createStatement.executeUpdatesql catch SQLException e System.out.printlne.getMessage //ife.getMessage.equalsquotMicrosoftSQLServer 2000Driver for JDBCSQLServerDELETE 语句与 COLUMN REFERENCE 约束FK_TB_BORRO_REFERENCE_TB_BOOKI 冲突。
该冲突发生于数据库 db_library,表tb_borrow column bookISBN。
quot return -1 finally //关闭数据库 public static void close try conn.close catch SQLException e e.printStackTrace finally conn null / 管理员登录方法 / public static Operator checkString name String password int i 0 Operator operaternew Operator String
sql quotselect from tb_operator where namequot name quot and passwordquot password quotand admin1quot ResultSet rs Dao.executeQuerysql try while rs.next String names rs.getString1 operater.setIdrs.getStringquotidquot operater.setNamers.getStringquotnamequot operater.setGraders.getStringquotadminquot 4 Java 开发实例 源码——图书信息管理系统 operater.setPasswordrs.getStringquotpasswordquot if names null i 1 catch Exception e e.printStackTrace Dao.close return operater / 查询类别方法 ///查询图书目录 public static List selectBookCategory List listnew ArrayList String
sql quotselect from tb_bookTypequot ResultSet rs Dao.executeQuerysql try while rs.next BookType bookTypenew BookType bookType.setIdrs.getStringquotidquot bookType.setTypeNamers.getStringquottypeNamequot list.addbookType catch Exception e e.printStackTrace Dao.close return list public static List selectBookCategoryString bookType List listnew ArrayList String
sql quotselect days from tb_bookType wheretypeNamequotbookTypequotquot ResultSet rs Dao.executeQuerysql try while rs.next BookType typenew BookType type.setDaysrs.getStringquotdaysquot list.addtype 5 Java 开发实例 源码——图书信息管理系统 catch Exception e e.printStackTrace Dao.close return list / 图书类别表相关操作 ///插入图书类型 public static int InsertBookTypeString bookTypeName int i0 try String sqlquotinsert into tb_bookTypetypeNamevaluesquotbookTypeNamequotquot iDao.executeUpdatesql catchException e e.printStackTrace return i //更新图书类别 public static int UpdatebookTypeString idString typeName int i0 try String sqlquotupdate tb_bookType set typeNamequottypeNamequotwhere idquotidquotquot //System.out.printlnsql iDao.executeUpdatesql catchException e e.printStackTrace Dao.close return i //删除图书类别 public static int DelbookTypeString id int i0 try String sqlquotdelete from tb_bookType where idquotidquotquot //System.out.printlnsql iDao.executeUpdatesql 6 Java 开发实例 源码——图书信息管理系统 catchException e e.printStackTrace Dao.close return i / 图书信息表相关操作 / / 插入图书信息方法 ///插入图书信息 public static int InsertbookString ISBNString typeIdStringbooknameString writerString translatorString publisherDatedateDouble price int i0 try String sqlquotinsert intotb_bookInfoISBNtypeIdbooknamewritertranslatorpublisherdatepricevaluesquotISBNquotquottypeIdquotquotbooknamequotquotwriterquotquottranslatorquotquotpublisherquotquotdatequotquotpricequotquot //System.out.printlnsql iDao.executeUpdatesql catchException e System.out.printlne.getMessage Dao.close return i / 查询图书相关信息 / public static List selectBookInfo List listnew ArrayList String
sql quotselect from tb_bookInfoquot ResultSet rs Dao.executeQuerysql try while rs.next BookInfo bookinfonew BookInfo bookinfo.setISBNrs.getStringquotISBNquot bookinfo.setTypeidrs.getStringquottypeidquot 7 Java 开发实例 源码——图书信息管理系统 bookinfo.setBooknamers.getStringquotbooknamequot bookinfo.setWriterrs.getStringquotwriterquot bookinfo.setTranslatorrs.getStringquottranslatorquot bookinfo.setPublisherrs.getStringquotpublisherquot bookinfo.setDaters.getDatequotdatequot bookinfo.setPricers.getDoublequotpricequot list.addbookinfo catch Exception e e.printStackTrace Dao.close return list public static List selectBookInfoString ISBN List listnew ArrayList String
sql quotselect from tb_bookInfo where ISBNquotISBNquotquot ResultSet rs Dao.executeQuerysql try while rs.next BookInfo bookinfonew BookInfo bookinfo.setISBNrs.getStringquotISBNquot bookinfo.setTypeidrs.getStringquottypeidquot bookinfo.setBooknamers.getStringquotbooknamequot bookinfo.setWriterrs.getStringquotwriterquot bookinfo.setTranslatorrs.getStringquottranslatorquot bookinfo.setPublisherrs.getStringquotpublisherquot bookinfo.setDaters.getDatequotdatequot bookinfo.setPricers.getDoublequotpricequot list.addbookinfo catch Exception e e.printStackTrace Dao.close return list / 修改图书信息方法 ///更新图书信息 public static int UpdatebookString ISBNString typeIdStringbooknameString writerString translatorString publisherDatedateDouble price 8 Java 开发实例 源码——图书信息管理系统 int i0 try String sqlquotupdate tb_bookInfo setISBNquotISBNquottypeIdquottypeIdquotbooknamequotbooknamequotwriterquotwriterquottranslatorquottranslatorquotpublisherquotpublisherquotdatequotdatequotpricequotpricequot where ISBNquotISBNquotquot //System.out.printlnsql iDao.executeUpdatesql catchException e e.printStackTrace Dao.close return i // /// 删除图书信息方法// / public static int DelbookString ISBN int i0 try String sqlquotdelete from tb_bookInfo where ISBNquotISBNquotquot //System.out.printlnsql iDao.executeUpdatesql catchException e e.printStackTrace Dao.close return i / 对读者信息表执行的相关操作 ///增加读者信息 public static int InsertReaderString nameString sexStringageString identityCardDate dateString maxNumString telDoublekeepMoneyString zjString zyDate bztimeString ISBN int i0 try String sqlquotinsert intotb_readernamesexageidentityCarddatemaxNumtelkeepMoneyzjzybztimeISBNvaluesquotnamequotquotsexquotquotagequotquotidentityCardquotquotdatequotquotmaxNumquotquottelquotquotkeepMoneyquotquotzjquotquotzyquotquotbztimequotquotISBNquotquot 9 Java 开发实例 源码——图书信息管理系统 System.out.printlnsql iDao.executeUpdatesql catchException e e.printStackTrace Dao.close return i public static List selectReader List listnew ArrayList String
sql quotselect from tb_readerquot ResultSet rs Dao.executeQuerysql try while rs.next Reader readernew Reader //reader.setIdrs.getStringquotidquot reader.setNamers.getStringquotnamequot reader.setSexrs.getStringquotsexquot reader.setAgers.getStringquotagequot reader.setIdentityCardrs.getStringquotidentityCardquot reader.setDaters.getDatequotdatequot reader.setMaxNumrs.getStringquotmaxNumquot reader.setTelrs.getStringquottelquot reader.setKeepMoneyrs.getDoublequotkeepMoneyquot reader.setZjrs.getIntquotzjquot reader.setZyrs.getStringquotzyquot reader.setISBNrs.getStringquotISBNquot reader.setBztimers.getDatequotbztimequot list.addreader catch Exception e e.printStackTrace Dao.close return list public static List selectReaderString readerISBN List listnew ArrayList String
sql quotselect from tb_reader whereISBNquotreaderISBNquotquot ResultSet rs Dao.executeQuerysql try while rs.next Reader readernew Reader 10 Java 开发实例 源码——图书信息管理系统 reader.setNamers.getStringquotnamequot reader.setSexrs.getStringquotsexquot reader.setAgers.getStringquotagequot reader.setIdentityCardrs.getStringquotidentityCardquot reader.setDaters.getDatequotdatequot reader.setMaxNumrs.getStringquotmaxNumquot reader.setTelrs.getStringquottelquot reader.setKeepMoneyrs.getDoublequotkeepMoneyquot reader.setZjrs.getIntquotzjquot reader.setZyrs.getStringquotzyquot reader.setISBNrs.getStringquotISBNquot reader.setBztimers.getDatequotbztimequot list.addreader catch Exception e e.printStackTrace Dao.close return list //更新读者信息 public static int UpdateReaderString idString nameStringsexString ageString identityCardDate dateString maxNumStringtelDouble keepMoneyString zjString zyDate.
上一篇:
Apusic应用服务器的数据源管理
下一篇:
传统衍生 时代兼容——解读何镜堂的“两观三性”