[CODE]
/*******图书信息窗体监听事件*******/
class huan_actionPerformed implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
String str="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=tushuguanli.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(str);
Statement stmt=conn.createStatement();
if(e.getSource()==bhuan)
{
JOptionPane.showMessageDialog(null,"你要还的书已经提交到数据库,谢谢阅读!","提示",JOptionPane.WARNING_MESSAGE);
/*****先删除原先存在的学号****/
stmt.executeUpdate("delete * from memory where 卡号 = '"+txtnum.getText()+"' and 书名='"+txtbook.getText()+"'");
/***********更新数据并存入到数据库*******/
stmt.executeUpdate("insert into memory values ('"+tnum.getText()+"','"+tbook.getText()+"','"+tautor.getText()+"','"+tchu.getText()+"','已还')");
/*try
{
String str1="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=tushuguanli.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(str1);
Statement stmt1=con.createStatement();
ResultSet rs1=stmt1.executeQuery("select * from book where 书名='"+txtbook.getText()+"'");
jtno.setText(rs1.getString("书号"));
jtname.setText(rs1.getString("书名"));
String type=rs1.getString("类别");
jctype.setSelectedItem(type);
jtautor.setText(rs1.getString("作者"));
jtchu.setText(rs1.getString("出版社"));
jtcount.setText(rs1.getString("数量"));
int count=Integer.parseInt(jtcount.getText());
count++;
jtcount.setText(String.valueOf(count));
stmt1.executeUpdate("delete * from book where 书名='"+txtbook.getText()+"'");
stmt1.executeUpdate("insert into book values('"+jtno.getText()+"','"+tbook.getText()+"','"+jctype.getSelectedItem()+"','"+tautor.getText()+"','"+tchu.getText()+"','"+jtcount.getText()+"')");
}
catch(Exception ee)
{
ee.printStackTrace();
}*/
}
if(e.getSource()==breturn)
{
/***显示还书界面***/
labnum.setVisible(true);
txtnum.setVisible(true);
labbook.setVisible(true);
txtbook.setVisible(true);
buthuan.setVisible(true);
/***隐藏图书信息***/
lnum.setVisible(false);
tnum.setVisible(false);
lbook.setVisible(false);
tbook.setVisible(false);
lautor.setVisible(false);
tautor.setVisible(false);
lchu.setVisible(false);
tchu.setVisible(false);
bhuan.setVisible(false);
breturn.setVisible(false);
}
}
catch(Exception ee)
{
ee.printStackTrace();
}
}
}
这是其中的一部分代码,总提示说:无效的游标状态,我也不知道是怎么回事.
[/CODE]