×

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:49 PM
Views: 4459
Tags: no tags
  1. try
  2.         {
  3.  
  4.            
  5.            String query = "SELECT * FROM tb_buyfish";
  6.  
  7.             st = this.con.createStatement();
  8.             rs = st.executeQuery(query);
  9.  
  10.             DefaultTableModel dtm = (DefaultTableModel) buyfish_tb.getModel();
  11.             dtm.setRowCount(0);
  12.  
  13.             while(rs.next()){
  14.                 String getfishname = rs.getString("fishname");
  15.                 String getcolor= rs.getString("color");
  16.                 String getsize= rs.getString("size");
  17.                 String getqty = rs.getString("qty");
  18.                 String getprice = rs.getString("price");
  19.                 String gettotprice = rs.getString("totalprice");
  20.                 String getdate = rs.getString("date");
  21.  
  22.                 //JOptionPane.showMessageDialog(null,getvehno);
  23.  
  24.                 dtm.insertRow(buyfish_tb.getRowCount(), new Object[]{getfishname , getcolor , getsize , getqty , getprice , gettotprice , getdate });
  25.             }
  26.         }
  27.         catch(Exception e)
  28.         {
  29.             JOptionPane.showMessageDialog(null,"buyfish table filling: " + e.getMessage());
  30.         }  
  31.