0
我只是新的連接MySql數據庫到我的Java GUI,我有這個問題。在一個按鈕中,我有兩個查詢,我希望第二個查詢在第一個查詢不可執行時不運行。如何停止第二個查詢運行時,第一個查詢是不可執行的java
我的繼承人按鈕動作:
private void addActionPerformed(java.awt.event.ActionEvent evt) {
theQuery("INSERT INTO `deliv`(`prod_code`, `client`, `address`,`quantity`,`delivery_date`,`deliv_code`) VALUES ('"+prodC.getText()+"','"+client.getText()+"','"+address.getText()+"','"+quantity.getText()+"','"+delivdate.getText()+"','"+delivCode.getText()+"')");
theQuery("Update product_list set prod_stock=prod_stock-'"+quantity.getText()+"'where b.prod_code="+prodC.getText());
this.setVisible(false);
new adminLogin().setVisible(true);
}
和我的繼承人theQuery
能夠執行的命令:
public void theQuery(String query){
Connection con = null;
Statement st = null;
try{
con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/dbsystem","root","");
st = con.createStatement();
st.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Success!");
}catch(Exception ex){
JOptionPane.showMessageDialog(null,ex.getMessage());
}
}
請幫我
請更改您的問題 - 這是不可理解的 –
*,並且當該按鈕中的第一個查詢不可執行時,如果第二個查詢中的查詢可執行,則第二個查詢仍在執行時不會執行* - no想法這是什麼意思 –
它現在編輯先生 – topher