Hello guys, i created a method that would set the value of my string so that when i pass it to another class, it would still contain the needed value:

This is the first class:

public Student getSelectedStudent(){
        Student selectedStudent = new Student();
        DefaultTableModel dtm = (DefaultTableModel) tblListOfStudents.getModel();
        String studentNum  = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 0).toString();
        String name = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 1).toString();
        String course = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 2).toString();
        String year= dtm.getValueAt(tblListOfStudents.getSelectedRow(), 3).toString();
        selectedStudent.setStudentNumber(studentNum);
        selectedStudent.setStudentName(name);
        selectedStudent.setCourse(course);
        selectedStudent.setYear(year);
        return selectedStudent;
    }
    public void  getNumber(){
        System.out.print("was here: ");
        EditStudent myEditStudent = new EditStudent();
        System.out.print("nakalampas ");
        Student num = new Student();
        num.setStudentNumber(getSelectedStudent().getStudentNumber());

        System.out.print("dumaan dito: "+num.getStudentNumber());
        myEditStudent.receiver(num);

    }
Button btnEdit = new JButton("Edit Student Data");
        btnEdit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {

                if(tblListOfStudents.getSelectedRow()==-1){
                    JOptionPane.showMessageDialog(frame, "No Student Data to Edit", "No Selected Student", JOptionPane.ERROR_MESSAGE);
                }else{
                    System.out.print("1: ");

                getNumber();
                    EditStudent myEditStudent = new EditStudent();
                    myEditStudent.editStudent();


                    //List<Student> studentList =writer.updater(selectedStudent);
                    //updateStudentListTable();

                }

this is the second class:

public void actionPerformed(ActionEvent e) {
                if(txtStudentName.getText().equals(" ")||txtAddYear.getText().equals(" ")||
                        Age.equals(" ") ||txtAddContactNumber.getText().equals(" ")||txtAddReligion.getText().equals(" ")||
                        txtAddBPlace.getText().equals(" ")| txtAddNationality.getText().equals(" ")||txtAddAddress.getText().equals(" ")||
                        txtAddParent.getText().equals(" ")||txtAddRelation.getText().equals(" ")||txtAddRContactNumber.getText().equals(" ")||
                        txtAddSYear.getText().equals(" ")||txtAddSection.getText().equals(" ") ||txtAddSchoolYear.getText().equals(" ") 
                        ){
                    noValue();
                    JOptionPane.showMessageDialog(null, "Please fill-up all the fields!");
                }else{

                Student myStudent = setAddNewStudent();
                DataFileWriter myDataFileWriter = new DataFileWriter();
                myDataFileWriter.updater(myStudent);
                    //  GradeDBWriter myDbWriter = new GradeDBWriter();


                    //      myDataFileWriter.updater(myNumber,myStudent);
                    //  myDbWriter.StudentGradeWriter(myStudent);


                    Menu myMenu = new Menu();
                    myMenu.Menu();
                    frame.dispose();
                }
            }

    public void receiver (Student no){
        DataFileWriter myDataFileWriter = new DataFileWriter();
        String  number = no.getStudentNumber();
        System.out.println("Nakarating sa receiver: "+ number);
        myDataFileWriter.tangap(number);


    }

this is the third class, where i needed the Student Number, so that i can create an edit feature in my program:

public List<Student>  updater(Student editMe){
        String url = "jdbc:mysql://localhost:3307/";
        String dbName = "Student";
        String driver = "com.mysql.jdbc.Driver";
        String userName = "root";
        String password = "1234";
        List<Student> studentList = new ArrayList<Student>();
        try {

            Class.forName(driver).newInstance();
            Connection conn = DriverManager.getConnection(url+dbName,userName,password);
            Statement st = conn.createStatement();
            ResultSet res = st.executeQuery("SELECT * FROM  bio");
                conn.close();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null,"Cannot Connect to Database! Contact Ate Con, Rosselle , and Lonilie NOW! as in RIGHT NOW! ahihih!!");
        }
        return studentList;
    }


    public String tangap(String bilang){
        System.out.println("nandito na siya YES!" +bilang);

        return bilang;
    }
}

I need to get the Student Number from the first class and send it to the second class so that i can compare it and update my databse, please help, thanks!

are they actual seperate classes? they just seem to be seperate methods to me.

can you be a bit more precise which String you are trying to pass from wich method (in which class) to which method (in which class) and where exactly it is null?

ok ok ok ...
here..

this is the first class:

What this does it it shows a table, and when the user clicks on a row, it gets the data from the selected row:

package app.ui;

import java.awt.Color;
import java.awt.EventQueue;

import java.util.List;



import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import javax.swing.border.CompoundBorder;



import app.model.Student;
import app.util.DataFileReader;
import app.util.DataFileWriter;


import javax.swing.JTextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ListOfStudents {

    private JFrame frame;
    protected JTable tblListOfStudents;
    private JTextField txtStudNo;
    String letter = "";
    String searchNa ="";
    String numero="";
    protected List<Student> search = null;


    /**
     * Launch the application.
     */
    public void ListOfStudents() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    ListOfStudents window = new ListOfStudents();
                    window.frame.setVisible(true);

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public ListOfStudents() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 800, 452);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JLabel lblListStudents = new JLabel("List of Students");
        lblListStudents.setBounds(46, 38, 136, 14);
        frame.getContentPane().add(lblListStudents);

        JScrollPane scrpListOfStudents = new JScrollPane();
        scrpListOfStudents.setBounds(46, 89, 433, 255);
        frame.getContentPane().add(scrpListOfStudents);

        tblListOfStudents = new JTable();
        tblListOfStudents.setModel(new DefaultTableModel(
                new Object[][] {
                },
                new String[] {
                        "Student Number", "Name", "Course", "Year"
                }
                ) {
            boolean[] columnEditables = new boolean[] {
                    false, false, false, false
            };
            public boolean isCellEditable(int row, int column) {
                return columnEditables[column];
            }
        });
        scrpListOfStudents.setViewportView(tblListOfStudents);

        JLabel lblSearchS = new JLabel("Search:");
        lblSearchS.setBounds(491, 38, 63, 14);
        frame.getContentPane().add(lblSearchS);

        txtStudNo = new JTextField();
        txtStudNo.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent arg0) {

                updateSearchTable();
            }
        });


        txtStudNo.setBounds(564, 35, 117, 20);
        frame.getContentPane().add(txtStudNo);
        txtStudNo.setColumns(10);

        JButton btnMainMenu = new JButton("Back to Main Menu");
        btnMainMenu.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                Menu myMenu = new Menu();
                myMenu.Menu();
                frame.dispose();
            }
        });
        btnMainMenu.setBounds(558, 126, 161, 23);
        frame.getContentPane().add(btnMainMenu);

        JButton btnDelete = new JButton("Delete Selected Student");
        btnDelete.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(tblListOfStudents.getSelectedRow()==-1){
                    JOptionPane.showMessageDialog(frame, "No Student to Remove", "No Selected Student", JOptionPane.ERROR_MESSAGE);
                }else{
                    Student selectedStudent = getSelectedStudent();

                    DataFileReader reader = new DataFileReader();

                    List<Student> studentList = reader.deleteStudent(selectedStudent);
                    updateStudentListTable();

                }

            }
        });
        btnDelete.setBounds(558, 160, 161, 23);
        frame.getContentPane().add(btnDelete);

        JButton btnEdit = new JButton("Edit Student Data");
        btnEdit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {

                if(tblListOfStudents.getSelectedRow()==-1){
                    JOptionPane.showMessageDialog(frame, "No Student Data to Edit", "No Selected Student", JOptionPane.ERROR_MESSAGE);
                }else{
                    System.out.print("1: ");

                getNumber();
                    EditStudent myEditStudent = new EditStudent();
                    myEditStudent.editStudent();


                    //List<Student> studentList =writer.updater(selectedStudent);
                    //updateStudentListTable();

                }

            }
        });
        btnEdit.setBounds(558, 194, 161, 23);
        frame.getContentPane().add(btnEdit);
        updateStudentListTable();
    }

    public void updateStudentListTable(){
        DefaultTableModel dtm = (DefaultTableModel) tblListOfStudents.getModel();
        dtm.getDataVector().removeAllElements();
        tblListOfStudents.updateUI();
        DataFileReader read = new DataFileReader();
        List<Student> studentList = read.StudentRecordReader();
        for (Student myStudent : studentList) {
            String[] rowData = new String[4];

            rowData[0] =myStudent.getStudentNumber();
            rowData[1] =myStudent.getStudentName();
            rowData[2] =myStudent.getCourse();
            rowData[3] = myStudent.getSYear();


            dtm.addRow(rowData);
        }
        tblListOfStudents.setBackground(Color.green);
        tblListOfStudents.updateUI();
    }





    public void updateSearchTable(){
        DefaultTableModel dtm = (DefaultTableModel) tblListOfStudents.getModel();
        dtm.getDataVector().removeAllElements();
        tblListOfStudents.updateUI();
        Student myStudent = new Student();
        letter = txtStudNo.getText();
        myStudent.setSearchNo(letter);
        //SearchStudentNumber mySearchStudent = new SearchStudentNumber();
        //  List<Student> studentList =mySearchStudent.SearchStudentRecordReader(myStudent);
        DataFileReader read = new DataFileReader();
        List<Student> studentList = read.StudentRecordReader();

        for (Student meStudent : studentList) {
            if(txtStudNo.getText().equals(meStudent.getStudentNumber())){

                String[] rowData = new String[4];

                rowData[0] =meStudent.getStudentNumber();
                rowData[1] =meStudent.getStudentName();
                rowData[2] =meStudent.getCourse();
                rowData[3] = meStudent.getSYear();


                dtm.addRow(rowData);
            }else if(txtStudNo.getText().equals("")){
                updateStudentListTable();
            }

        }
        tblListOfStudents.setBackground(Color.green);
        tblListOfStudents.updateUI();

    }

    public Student getSelectedStudent(){
        Student selectedStudent = new Student();
        DefaultTableModel dtm = (DefaultTableModel) tblListOfStudents.getModel();
        String studentNum  = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 0).toString();
        String name = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 1).toString();
        String course = dtm.getValueAt(tblListOfStudents.getSelectedRow(), 2).toString();
        String year= dtm.getValueAt(tblListOfStudents.getSelectedRow(), 3).toString();
        selectedStudent.setStudentNumber(studentNum);
        selectedStudent.setStudentName(name);
        selectedStudent.setCourse(course);
        selectedStudent.setYear(year);
        return selectedStudent;
    }


/* "getNumber" method communicates with the method in the next class*/
public void  getNumber(){
        System.out.print("was here: ");
        EditStudent myEditStudent = new EditStudent();
        System.out.print("nakalampas ");
        Student num = new Student();
        num.setStudentNumber(getSelectedStudent().getStudentNumber());


        myEditStudent.receiver(num);

    }

}

This is the second class:
what this dies is, it is a window where the user will be able to edit the data...

package app.ui;

import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JSpinner;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.DefaultComboBoxModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.ButtonGroup;

import app.encode.grade.db.GradeDBWriter;
import app.model.Student;
import app.util.DataFileWriter;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;

public class EditStudent {

    private JFrame frame;
    private JTextField txtStudentName;
    private JTextField txtAddContactNumber;
    private JTextField txtAddReligion;
    private JTextField txtAddBPlace;
    private JTextField txtAddNationality;
    private JTextField txtAddAddress;
    private JTextField txtAddParent;
    private JTextField txtAddRelation;
    private JTextField txtAddRContactNumber;
    private JTextField txtAddYear;
    private JTextField txtAddSYear;
    private JTextField txtAddSchoolYear;

    private JTextField txtAddSection;
    private String Month =" ";
    private String day = " ";
    private String Age = " ";
    private final ButtonGroup genderGroup = new ButtonGroup();
    private final ButtonGroup statusGroup = new ButtonGroup();
    JRadioButton rbtnAddMale;
    JRadioButton rbtnAddFemale;
    JRadioButton rbtnAddMarried;
    JRadioButton rbtnAddSingle;
    private String course =" ";
    private String fullBday=" ";



    /**
     * Launch the application.
     */
    public void editStudent() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    EditStudent window = new EditStudent();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public EditStudent() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 799, 476);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JLabel lblStudentName = new JLabel("Name:");
        lblStudentName.setBounds(35, 58, 46, 14);
        frame.getContentPane().add(lblStudentName);

        JLabel lblStudentAge = new JLabel("Age:");
        lblStudentAge.setBounds(35, 108, 46, 14);
        frame.getContentPane().add(lblStudentAge);

        JLabel lblStudentAddress = new JLabel("Address:");
        lblStudentAddress.setBounds(35, 301, 46, 14);
        frame.getContentPane().add(lblStudentAddress);

        JLabel lblStudentBday = new JLabel("Birthday:");
        lblStudentBday.setBounds(35, 83, 46, 14);
        frame.getContentPane().add(lblStudentBday);

        JLabel lblStudentGender = new JLabel("Gender:");
        lblStudentGender.setBounds(35, 158, 46, 14);
        frame.getContentPane().add(lblStudentGender);

        JLabel lblStudentGuardian = new JLabel("Parent/Guardian:");
        lblStudentGuardian.setBounds(35, 326, 87, 14);
        frame.getContentPane().add(lblStudentGuardian);

        JLabel lblGuardianContactNumber = new JLabel("Contact Number:");
        lblGuardianContactNumber.setBounds(93, 376, 87, 14);
        frame.getContentPane().add(lblGuardianContactNumber);

        JLabel lblContactNumber = new JLabel("Contact Number:");
        lblContactNumber.setBounds(35, 133, 104, 14);
        frame.getContentPane().add(lblContactNumber);

        JLabel lblRelation = new JLabel("Relation:");
        lblRelation.setBounds(93, 351, 46, 14);
        frame.getContentPane().add(lblRelation);

        JLabel lblStudentCivilStatus = new JLabel("Civil Status:");
        lblStudentCivilStatus.setBounds(35, 183, 87, 14);
        frame.getContentPane().add(lblStudentCivilStatus);

        JLabel lblNationality = new JLabel("Nationality:");
        lblNationality.setBounds(35, 258, 87, 14);
        frame.getContentPane().add(lblNationality);

        JLabel lblReligion = new JLabel("Religion:");
        lblReligion.setBounds(35, 208, 87, 14);
        frame.getContentPane().add(lblReligion);

        JLabel lblBPlace = new JLabel("Birth Place:");
        lblBPlace.setBounds(35, 233, 87, 14);
        frame.getContentPane().add(lblBPlace);

        JLabel lblStudentCourse = new JLabel("Subject:");
        lblStudentCourse.setBounds(542, 27, 46, 14);
        frame.getContentPane().add(lblStudentCourse);

        JLabel lblYear = new JLabel("Year:");
        lblYear.setBounds(542, 58, 46, 14);
        frame.getContentPane().add(lblYear);

        JLabel lblSection = new JLabel("Section:");
        lblSection.setBounds(542, 83, 46, 14);
        frame.getContentPane().add(lblSection);

        JLabel lblSchoolYear = new JLabel("S.Y :");
        lblSchoolYear.setBounds(542, 108, 46, 14);
        frame.getContentPane().add(lblSchoolYear);

        txtStudentName = new JTextField();
        txtStudentName.setColumns(10);
        txtStudentName.setBounds(132, 55, 302, 20);
        frame.getContentPane().add(txtStudentName);

        txtAddContactNumber = new JTextField();
        txtAddContactNumber.setColumns(10);
        txtAddContactNumber.setBounds(132, 130, 126, 20);
        frame.getContentPane().add(txtAddContactNumber);

        txtAddReligion = new JTextField();
        txtAddReligion.setColumns(10);
        txtAddReligion.setBounds(132, 205, 126, 20);
        frame.getContentPane().add(txtAddReligion);

        txtAddBPlace = new JTextField();
        txtAddBPlace.setColumns(10);
        txtAddBPlace.setBounds(132, 230, 126, 20);
        frame.getContentPane().add(txtAddBPlace);

        txtAddNationality = new JTextField();
        txtAddNationality.setColumns(10);
        txtAddNationality.setBounds(132, 255, 126, 20);
        frame.getContentPane().add(txtAddNationality);

        txtAddAddress = new JTextField();
        txtAddAddress.setColumns(10);
        txtAddAddress.setBounds(121, 298, 367, 20);
        frame.getContentPane().add(txtAddAddress);

        txtAddParent = new JTextField();
        txtAddParent.setColumns(10);
        txtAddParent.setBounds(121, 323, 302, 20);
        frame.getContentPane().add(txtAddParent);

        txtAddRelation = new JTextField();
        txtAddRelation.setColumns(10);
        txtAddRelation.setBounds(188, 348, 126, 20);
        frame.getContentPane().add(txtAddRelation);

        txtAddRContactNumber = new JTextField();
        txtAddRContactNumber.setColumns(10);
        txtAddRContactNumber.setBounds(188, 373, 126, 20);
        frame.getContentPane().add(txtAddRContactNumber);

        final JSpinner spnAddDay = new JSpinner();
        spnAddDay.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent arg0) {
                day = spnAddDay.getModel().getValue().toString();

            }
        });
        spnAddDay.setModel(new SpinnerNumberModel(1, 1, 31, 1));
        spnAddDay.setBounds(246, 80, 41, 20);
        frame.getContentPane().add(spnAddDay);

        final JComboBox cmbAddMonth = new JComboBox();
        cmbAddMonth.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                Month = (String)cmbAddMonth.getSelectedItem();

            }
        });
        cmbAddMonth.setModel(new DefaultComboBoxModel(new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}));
        cmbAddMonth.setBounds(128, 80, 108, 20);
        frame.getContentPane().add(cmbAddMonth);

        txtAddYear = new JTextField();
        txtAddYear.setColumns(10);
        txtAddYear.setBounds(297, 80, 55, 20);
        frame.getContentPane().add(txtAddYear);

        final JComboBox cmbAddAge = new JComboBox();
        cmbAddAge.setModel(new DefaultComboBoxModel(new String[] {"12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60"}));
        cmbAddAge.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                Age = (String)cmbAddAge.getSelectedItem();
            }
        });
        cmbAddAge.setBounds(132, 105, 68, 20);
        frame.getContentPane().add(cmbAddAge);

        rbtnAddMale = new JRadioButton("Male");
        genderGroup.add(rbtnAddMale);
        //  genderGroup.add(rbtnAddMale);
        rbtnAddMale.setBounds(127, 154, 109, 23);
        frame.getContentPane().add(rbtnAddMale);

        rbtnAddFemale = new JRadioButton("Female");
        genderGroup.add(rbtnAddFemale);
        //  genderGroup.add(rbtnAddFemale);
        rbtnAddFemale.setBounds(243, 154, 109, 23);
        frame.getContentPane().add(rbtnAddFemale);

        rbtnAddSingle = new JRadioButton("Single");
        statusGroup.add(rbtnAddSingle);
        //  statusGroup.add(rbtnAddSingle);
        rbtnAddSingle.setBounds(127, 179, 109, 23);
        frame.getContentPane().add(rbtnAddSingle);

        rbtnAddMarried = new JRadioButton("Married");
        statusGroup.add(rbtnAddMarried);
        //  statusGroup.add(rbtnAddMarried);
        rbtnAddMarried.setBounds(243, 179, 109, 23);
        frame.getContentPane().add(rbtnAddMarried);

        final JComboBox cmbAddCourse = new JComboBox();
        cmbAddCourse.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                course = cmbAddCourse.getSelectedItem().toString();

            }
        });
        cmbAddCourse.setModel(new DefaultComboBoxModel(new String[] {"BSIT", "BSCS"}));
        cmbAddCourse.setBounds(598, 24, 108, 20);
        frame.getContentPane().add(cmbAddCourse);

        txtAddSYear = new JTextField();
        txtAddSYear.setColumns(10);
        txtAddSYear.setBounds(595, 55, 55, 20);
        frame.getContentPane().add(txtAddSYear);

        txtAddSchoolYear = new JTextField();
        txtAddSchoolYear.setColumns(10);
        txtAddSchoolYear.setBounds(595, 105, 111, 20);
        frame.getContentPane().add(txtAddSchoolYear);

        JButton btnAddEditedStudent = new JButton("Update Record");
        btnAddEditedStudent.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(txtStudentName.getText().equals(" ")||txtAddYear.getText().equals(" ")||
                        Age.equals(" ") ||txtAddContactNumber.getText().equals(" ")||txtAddReligion.getText().equals(" ")||
                        txtAddBPlace.getText().equals(" ")| txtAddNationality.getText().equals(" ")||txtAddAddress.getText().equals(" ")||
                        txtAddParent.getText().equals(" ")||txtAddRelation.getText().equals(" ")||txtAddRContactNumber.getText().equals(" ")||
                        txtAddSYear.getText().equals(" ")||txtAddSection.getText().equals(" ") ||txtAddSchoolYear.getText().equals(" ") 
                        ){
                    noValue();
                    JOptionPane.showMessageDialog(null, "Please fill-up all the fields!");
                }else{

                Student myStudent = setAddNewStudent();
                DataFileWriter myDataFileWriter = new DataFileWriter();
                myDataFileWriter.updater(myStudent);
                    //  GradeDBWriter myDbWriter = new GradeDBWriter();


                    //      myDataFileWriter.updater(myNumber,myStudent);
                    //  myDbWriter.StudentGradeWriter(myStudent);


                    Menu myMenu = new Menu();
                    myMenu.Menu();
                    frame.dispose();
                }
            }
        });
        btnAddEditedStudent.setBounds(573, 322, 143, 23);
        frame.getContentPane().add(btnAddEditedStudent);

        JButton btnClearFields = new JButton("Reset");
        btnClearFields.setBounds(573, 297, 143, 23);
        frame.getContentPane().add(btnClearFields);

        JButton btnAddCancel = new JButton("Cancel");
        btnAddCancel.setBounds(573, 273, 143, 23);
        frame.getContentPane().add(btnAddCancel);

        txtAddSection = new JTextField();
        txtAddSection.setColumns(10);
        txtAddSection.setBounds(598, 81, 111, 20);
        frame.getContentPane().add(txtAddSection);
    }



    public Student setAddNewStudent(){
        Student myStudent = new Student();



        myStudent.setStudentName(txtStudentName.getText());
        fullBday = Month + day + txtAddYear.getText();
        myStudent.bdayMoTalaga(fullBday);
        myStudent.setAge(Age);
        myStudent.setContactNumber(txtAddContactNumber.getText());
        setRadioGender(myStudent);
        setRadioStatus(myStudent);
        myStudent.setReligion(txtAddReligion.getText());
        myStudent.setBPlace(txtAddBPlace.getText());
        myStudent.setNationality(txtAddNationality.getText());
        myStudent.setAddress(txtAddAddress.getText());
        myStudent.setParent(txtAddParent.getText());
        myStudent.setRelation(txtAddRelation.getText());
        myStudent.setRContactNumber(txtAddRContactNumber.getText());
        myStudent.setCourse(course);
        myStudent.setSYear(txtAddSYear.getText());
        myStudent.setSection(txtAddSection.getText());
        myStudent.setSchoolYear(txtAddSchoolYear.getText());    


        return myStudent;
    }

    public void setRadioGender(Student myStudent){
        if (genderGroup.getSelection().equals(rbtnAddFemale.getModel())){
            myStudent.setGender("Female");
            System.out.print(rbtnAddFemale.getText());
        }else{
            myStudent.setGender("Male");
            System.out.print(rbtnAddMale.getText());
        }

    }

    public void setRadioStatus(Student myStudent){
        if (statusGroup.getSelection().equals(rbtnAddMarried.getModel())){
            myStudent.setCivilStatus("Married");
            System.out.print(rbtnAddMarried.getText());
        }
        else if  (statusGroup.getSelection().equals(rbtnAddSingle.getModel())){
            myStudent.setCivilStatus("Single");
            System.out.print(rbtnAddSingle.getText());
        }else{
            JOptionPane.showMessageDialog(null, "Did not select any!");
        }

    }

    public void noValue(){
        Student myStudent = new Student();



        txtStudentName.setText("");
        txtAddYear.setText("");
        fullBday= "";
        Age = "";
        txtAddContactNumber.setText("");
        txtAddReligion.setText("");
        txtAddBPlace.setText("");
        txtAddNationality.setText("");
        txtAddAddress.setText("");
        txtAddParent.setText("");
        txtAddRelation.setText("");
        txtAddRContactNumber.setText("");
        course = "";
        txtAddSYear.setText("");
        txtAddSection.setText("");
        txtAddSchoolYear.setText("");   


        txtStudentName.setBackground(Color.red);
        txtAddYear.setBackground(Color.red);
        txtAddContactNumber.setBackground(Color.red);
        txtAddReligion.setBackground(Color.red);
        txtAddBPlace.setBackground(Color.red);
        txtAddNationality.setBackground(Color.red);
        txtAddAddress.setBackground(Color.red);
        txtAddParent.setBackground(Color.red);
        txtAddRelation.setBackground(Color.red);
        txtAddRContactNumber.setBackground(Color.red);

        txtAddSYear.setBackground(Color.red);
        txtAddSection.setBackground(Color.red);
        txtAddSchoolYear.setBackground(Color.red);

    }

    public void receiver (Student no){
        DataFileWriter myDataFileWriter = new DataFileWriter();
        String  number = no.getStudentNumber();
        System.out.println("Nakarating sa receiver: "+ number);
        myDataFileWriter.tangap(number);


    }


}

and this is the thrid class that is responsible for updating the data in the databse, "updater" method in particular.

package app.util;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

import javax.sound.midi.Receiver;
import javax.swing.JOptionPane;

import app.model.Student;
import app.ui.ListOfStudents;
public class DataFileWriter {


    public void StudentRecordWriter(Student myStudent) {
        String url = "jdbc:mysql://localhost:3307/";
        String dbName = "Student";
        String driver = "com.mysql.jdbc.Driver";
        String userName = "root";
        String password = "1234";
        try {

            Class.forName(driver).newInstance();
            Connection conn = DriverManager.getConnection(url+dbName,userName,password);
            Statement st = conn.createStatement();
            ResultSet res = st.executeQuery("SELECT * FROM  bio");
            /*while (res.next()) {
                int id = res.getInt("studentNo");
                String msg = res.getString("Name");
                System.out.println(id + "\t" + msg);
            }*/




            int laman = st.executeUpdate("INSERT INTO bio VALUES('"+myStudent.getStudentNumber()+"','"+ myStudent.getStudentName()+"','"+myStudent.bdayMoTalaga()+"','"+myStudent.getAge()+"','"+myStudent.getContactNumber()+"','"+myStudent.getGender()+"','"+myStudent.getCivilStatus()+"','"+myStudent.getReligion()+"', '"+myStudent.getBPlace()+"', '"+myStudent.getNationality()+"', '"+myStudent.getAddress()+"', '"+myStudent.getParent()+"', '"+myStudent.getRelation()+"', '"+myStudent.getRContactNumber()+"', '"+myStudent.getCourse()+"', '"+myStudent.getSYear()+"', '"+myStudent.getSection()+"', '"+myStudent.getSchoolYear()+"' )");                           

            if (laman==1){
            JOptionPane.showMessageDialog(null,"Succesfully Added a Student!! ");
            }

            conn.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"Cannot Connect to Database! ");
        }

    }


    public List<Student>  updater(Student editMe){
        String url = "jdbc:mysql://localhost:3307/";
        String dbName = "Student";
        String driver = "com.mysql.jdbc.Driver";
        String userName = "root";
        String password = "1234";
        List<Student> studentList = new ArrayList<Student>();
        try {

            Class.forName(driver).newInstance();
            Connection conn = DriverManager.getConnection(url+dbName,userName,password);
            Statement st = conn.createStatement();
            ResultSet res = st.executeQuery("SELECT * FROM  bio");
            /*while (res.next()) {

        int id = res.getInt("studentNo");
                String msg = res.getString("Name");
                System.out.println(id + "\t" + msg);
            }*/


            int laman = st.executeUpdate("UPDATE bio SET  studentName ='"+editMe.getStudentName()+"' WHERE studentNo = '"+no+"'");

        if (laman==1){
        JOptionPane.showMessageDialog(null,"Succesfully Added a Student!! ");
            }

            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null,"Cannot Connect to Database! ");
        }
        return studentList;
    }

public String tangap(String bilang){
        System.out.println("nandito na siya YES!" +bilang);

        return bilang;
    }
}

// status = '"+editMe.getCivilStatus()+"'  religion = '"+editMe.getReligion()+"' birthPlace = '"+editMe.getBPlace()+"' nationality = '"+editMe.getNationality()+"' address = '"+editMe.getAddress()+"' parent =  '"+editMe.getParent()+"' relation = '"+editMe.getRelation()+"' rcontact = '"+editMe.getRContactNumber()+"' course = '"+editMe.getCourse()+"' syear = '"+editMe.getSYear()+"' section = '"+editMe.getSection()+"' schoolYear = '"+editMe.getSchoolYear()+"' WHERE studentNo = '"+editMe.getStudentNumber()+"' ");

You are refering to methods and not classes.
Pass it as a parameter in the method you want to use .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.