文档详情

Java程序设计_大作业.doc

发布:2018-06-11约1.7万字共34页下载文档
文本预览下载声明
Java程序设计_大作业 专业:计算机科学与技术专业 学号:1245713131 姓名: 2014年12月10日 目录 作业内容: 2 1.IPublisherDao接口: 3 2.IPublisherDao类: 4 3.Publisher类: 13 4.DataBaseConnection类: 15 5.TestFrame类: 18 6.RunApplication类: 29 具体运行结果: 29 总结: 33 大作业:Java 数据库程序设计 作业内容: 图书馆要进行出版商的统计,如下图所示。要求创建一个具有交互功能的用户接口的出版商信息应用程序,列表的信息从数据库查询,动态添加。该应用程序应该使管理人员能够从出版商表中添加、更新信息。要求使用PreparedStatement对象创建SQL语句。 1.IPublisherDao接口: package com.zy.dao; import java.util.List; import com.zy.entity.Publisher; public interface IPublisherDao { public boolean doCreate(Publisher publisher) throws Exception; public boolean doUpdate(Publisher publisher) throws Exception; public boolean doDelete(String id) throws Exception; public Publisher findById(String id) throws Exception; public ListPublisher findAll(String keyword) throws Exception; public ListPublisher all() throws Exception; } 2.IPublisherDao类: package com.zy.dao; import java.sql.Connection; import java.sql.ResultSet; import java.sql.PreparedStatement; import java.util.ArrayList; import java.util.List; import com.zy.entity.Publisher; import com.zy.jdbc.DataBaseConnection; public class IPublisherDaoImpl implements IPublisherDao{ private DataBaseConnection jdbc=null; private Connection con=null; public IPublisherDaoImpl(){ this.jdbc=new DataBaseConnection(); this.con=this.jdbc.getConnection(); } @Override public boolean doCreate(Publisher publisher) throws Exception { boolean flag=false; PreparedStatement pstmt=null; ResultSet rs=null; String sql=INSERT INTO Publisher(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.setString(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
显示全部
相似文档