I am trying to add a value from my database table to a JFormattedTextField
trouble is the setText function is not working or i did something wrong?? i want the data from database to show at TextField
Frame class is below (where all the button and TextField is)
JFormattedTextField name are set like this Tb_Basic_CR_ACP
public class AdminControlPanelFrame extends javax.swing.JFrame {
     public void setText1(String text){
     Tb_Basic_CR_ACP.setText(text);
     }
     public void setText2(String text){
     Tb_Premium_CR_ACP.setText(text);
     }
     public void setText3(String text){
     Tb_Gold_CR_ACP.setText(text);
     }
     public void setText4(String text){
     Tb_FRate_CR_ACP.setText(text);
     }
}
this is the other class
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import javax.swing.JOptionPane;
 public class ShowDataDB {
 Connection conn;
 ResultSet rs;
 PreparedStatement pst;
 AdminControlPanelFrame ACP = new AdminControlPanelFrame();
 public void ACP_CurrentRate(){
   conn=JavaConnection.ConnecrDb();
   String sql = "select * from Rate where ID='"+1+"'";
       try{
             pst=conn.prepareStatement(sql);
             rs = pst.executeQuery();
           if(rs.next()){
           String add1 = rs.getString("Basic");
           ACP.setText1(add1);
           String add2 = rs.getString("Premium");
           ACP.setText2(add2);
           String add3 = rs.getString("Gold");
           ACP.setText3(add3);
           String add4 = rs.getString("Fix");
           ACP.setText4(add4);
   }
     }catch(Exception e){
         JOptionPane.showMessageDialog(null, e);
 }
 }
Thanks for helping in advance
Aucun commentaire:
Enregistrer un commentaire