数据库课程设计报告图书管理系统 下载本文

JOptionPane.showMessageDialog(null,\图书信息删除失败,该 图书 ID 号不存在\警告\.WARNING_MESSAGE);

res=false; rs.close(); stmt.close(); }

}catch (SQLException e)

{

JOptionPane.showMessageDialog(null,\图书信息删除失败\功 \.INFORMATION_MESSAGE);

res=false;

System.out.print(\

e.printStackTrace(); } return res; }

成4)修改图书信息:

public static boolean modifyBook(Book oldBook) { Connection connect=getConnection();

boolean flag=false; try {

Statement stmt = connect.createStatement(); //查询集 String sqlString=\

Bname='\.getBname()+\

Bauthor='\.getBauthor() +\Press='\.getPress()+\

BInfo='\.getBinfo()+\.getYear()+\+

oldBook.getMonth()+\.getDay()+\ oldBook.getBclass()+\

where BID='\.getBID()+\stmt.executeUpdate(sqlString);

JOptionPane.showMessageDialog(null,\图书信息修改成功\成功

\.INFORMATION_MESSAGE); flag=true;

}catch (SQLException e) //捕获错误

{ JOptionPane.showMessageDialog(null,\图书信息修改失败\警告

\.WARNING_MESSAGE);

flag=false;

System.out.print(\ e.printStackTrace(); }

return flag; }

5)修改一条图书记录并将结果用表格显示出来: public

{ javax.swing.ListSelectionModel;

javax.swing.RowSorter; javax.swing.table.DefaultTableModel;

javax.swing.table.TableRowSorter;

class BookInfoQuery extends JFrame

BorderLayout borderLayout1 = new BorderLayout();//布局方式 JSplitPane jSplitPane1 = new JSplitPane();//分割面板

JScrollPane jScrollPane1 = new JScrollPane();//滚动面板,用于放置表格 JPanel jPanel1 = new JPanel();//面板 JTable jTable1 = new JTable();//表格

DefaultTableModel tablemodel = null;//默认表格模型 JPanel jPanel3 = new JPanel();//面板

GridLayout gridLayout1 = new GridLayout();// 网格布局方式 JButton jBexit = new JButton();//退出按钮 ListSelectionModel selectionMode=null;

public BookInfoQuery(String bID,String bname,String bauthor, String press,

String bInfo,String year,String month,String day,String bclass)

{ getContentPane().setLayout(borderLayout1);//设置布局方式