Java 我的insert语句将相同的数据保存在两列中,并忽略第二列的值
以下是我的java代码:Java 我的insert语句将相同的数据保存在两列中,并忽略第二列的值,java,mysql,Java,Mysql,以下是我的java代码: BorrowBook issue = new BorrowBook(Integer.parseInt(txtUserid.getText()), Integer.parseInt(txtBookid.getText()), ((JTextComponent)Dateborrow.getDateEditor().getUiCompone
BorrowBook issue = new BorrowBook(Integer.parseInt(txtUserid.getText()),
Integer.parseInt(txtBookid.getText()),
((JTextComponent)Dateborrow.getDateEditor().getUiComponent()).getText(),
((JTextComponent)Datereturn.getDateEditor().getUiComponent()).getText());
Statement stmt = conn.createStatement();
String SQL= "select* from guest where GuestiD= " +issue.getguestid()+ "";
rs=stmt.executeQuery(SQL);
if(rs.next()){
// Statement stmt = conn.createStatement();
String sql = "Insert into bookissue (GuestiD,BookiD,BorrowDate,ReturnDate) Values("+issue.getguestid()+ ","+issue.getbookid()+",'" +issue.getborrowdate()+ "','"+issue.getreturndate()+"')";
stmt.executeUpdate(sql);
stmt.executeUpdate(sql2);
JOptionPane.showMessageDialog(null, "Book Borrowed Successfully");
}else{
JOptionPane.showMessageDialog(null, "ID NOT FOUND","ERROR",JOptionPane.ERROR_MESSAGE);
}
我的班级:
public class BorrowBook extends IssueBook {
public BorrowBook(int guestid, int bookid, String borrowdate, String returndate) {
super(guestid,bookid, borrowdate, returndate);
}
省略值是什么意思?它不是持久的吗?您是否已调试以查看
txtBookid
的值?还有,第二个更新是什么,使用sql2
,它在做什么?省略我的意思是它隐藏了值。SqL2i实际上在中间有一个更新语句,什么是<代码> SqL2内容?此外,您能否提供您的发行电子书
课程?