使用jtable在sqlite数据库中插入数据

时间:2014-02-22 09:30:31

标签: java sqlite

private void bSaveActionPerformed(java.awt.event.ActionEvent evt){
        int rows = aw.getRowCount();         for(int i = 0; i

    try{ 
        String sql = "INSERT INTO Sales (ProductID,BuyerID,Quantity,Discount,Transactiontype,TransactionDate) values (?,?,?,?,?,?)"; 
        pst = conn.prepareStatement(sql); 
        pst.setString(1, productID.getText()); 
        pst.setString(2,buyerid.getText()); 
        pst.setString(3, prodQty.getText()); 
        pst.setString(4, dc1.getText()); 
        pst.setString(5, Type.getSelectedItem().toString()); 
        pst.setString(6, dt.getText()); 
        pst.execute(); 
        //JOptionPane.showMessageDialog(null, "Saved"); 
        rs.close(); 
        pst.close(); 
    }catch(Exception e){ 
        JOptionPane.showMessageDialog(null, e); 
    } 
    JOptionPane.showMessageDialog(null, "Saved!");} 
}  

0 个答案:

没有答案