Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Yts 95
Added: Jul 6, 2020 1:38 PM
Views: 102
Tags: no tags
  1.  try{
  2.             String sql = "INSERT INTO tb_buyfish(fishname , color , size , qty , price , totalprice , date) VALUES(? , ? , ? , ? ,  ? , ? , ?) ";
  3.             pst  = this.con.prepareStatement(sql);
  4.            
  5.             pst.setString(1 , buyfish_fishname.getText());
  6.             pst.setString(2 , buyfish_color.getText());
  7.             pst.setString(3 , buyfish_size.getText());
  8.             pst.setString(4 , buyfish_qty.getText());
  9.             pst.setString(5 , buyfish_price.getText());
  10.             pst.setString(6 , buyfish_totalprice.getText());
  11.             java.util.Date get  = buyfish_date.getDate();
  12.                 String getdate = new SimpleDateFormat("yyyy/MM/dd").format(get);
  13.             pst.setString(7 , getdate);
  14.            
  15.             pst.executeUpdate();
  16.            
  17.             JOptionPane.showMessageDialog(null,"successfully!");
  18.     }
  19.     catch(Exception e){
  20.    
  21.         JOptionPane.showMessageDialog(null,"BuyFish_Save: " + e.getMessage());
  22.    
  23.     }