资源描述:
《java程序设计_大作业》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java程序设计_大作业专业:计算机科学与技术专业学号:1245713131姓名:2014年12月10日1目录作业内容:21.IPublisherDao接口:32.IPublisherDao类:43.Publisher类:134.DataBaseConnection类:155.TestFrame类:186.RunApplication类:29具体运行结果:29总结:3333大作业:Java数据库程序设计作业内容:图书馆要进行出版商的统计,如下图所示。要求创建一个具有交互功能的用户接口的出版商信息应用程序,列表的信息从数据库查询
2、,动态添加。该应用程序应该使管理人员能够从出版商表中添加、更新信息。要求使用PreparedStatement对象创建SQL语句。331.IPublisherDao接口:packagecom.zy.dao;importjava.util.List;importcom.zy.entity.Publisher;publicinterfaceIPublisherDao{publicbooleandoCreate(Publisherpublisher)throwsException;publicbooleandoUpdate(Publ
3、isherpublisher)throwsException;publicbooleandoDelete(Stringid)throwsException;publicPublisherfindById(Stringid)throwsException;33publicListfindAll(Stringkeyword)throwsException;publicListall()throwsException;}2.IPublisherDao类:packagecom.zy.dao;
4、importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.PreparedStatement;importjava.util.ArrayList;importjava.util.List;importcom.zy.entity.Publisher;importcom.zy.jdbc.DataBaseConnection;publicclassIPublisherDaoImplimplementsIPublisherDao{privateDataBaseC
5、onnectionjdbc=null;privateConnectioncon=null;publicIPublisherDaoImpl(){this.jdbc=newDataBaseConnection();this.con=this.jdbc.getConnection();}@Override33publicbooleandoCreate(Publisherpublisher)throwsException{booleanflag=false;PreparedStatementpstmt=null;ResultSetrs
6、=null;Stringsql="INSERTINTOPublisher(Publisher_ID,Publisher_Name,Phone_Number,Address,City,State,Zip)VALUES(?,?,?,?,?,?,?)";try{pstmt=this.con.prepareStatement(sql);pstmt.setString(1,publisher.getPublisherId());pstmt.setString(2,publisher.getPublisherName());pstmt.s
7、etString(3,publisher.getPhoneNum());pstmt.setString(4,publisher.getAddress());pstmt.setString(5,publisher.getCity());pstmt.setString(6,publisher.getState());pstmt.setString(7,publisher.getZip());if(pstmt.executeUpdate()>0){flag=true;}}catch(Exceptione){throwe;33}fin
8、ally{this.jdbc.closeAll(con,pstmt,rs);}returnflag;}@OverridepublicbooleandoUpdate(Publisherpublisher)throwsException{booleanflag=false;Pre