Hello!
i need to filter the searched data in the database sql and display it on the table. But i keep on getting tis error:

java.lang.StringIndexOutOfBoundsException: String index out of range: 1
    at java.lang.String.charAt(Unknown Source)
    at app.SearchByKey.SearchStudentNumber.SearchStudentRecordReader(SearchStudentNumber.java:38)
    at app.ui.ListOfStudents.updateSearchTable(ListOfStudents.java:159)
    at app.ui.ListOfStudents$3.keyReleased(ListOfStudents.java:105)
    at java.awt.Component.processKeyEvent(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

I think its because i printed that instance of myStudent and it prints null,
but i can't find what should i change to make it right.

this is my code.

package app.ui;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.FlowLayout;
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.SearchByKey.SearchStudentNumber;
import app.model.Student;
import app.search.student.list.SearchStudent;
import app.util.DataFileReader;
import javax.swing.JTextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class ListOfStudents {

    private JFrame frame;
    protected JTable tblListOfStudents;
    private JTextField txtStudNo;
    String letter = "";
    String searchNa ="";
    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) {

                //System.out.println("unaMeron: "+ myStudent.getStudentName());

                updateSearchTable();



            }
        });


        txtStudNo.setBounds(564, 35, 117, 20);
        frame.getContentPane().add(txtStudNo);
        txtStudNo.setColumns(10);
        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 Student setSearch(){
            Student myStudent = new Student();

            letter = txtStudNo.getText();
            myStudent.setSearchNo(letter);
            return myStudent;

        }*/

    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);

        for (Student meStudent : studentList) {
            String[] rowData = new String[4];

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


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

this is the second class
this should set the List that is contained by the table:

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

import javax.swing.JOptionPane;


import app.model.Student;

public class SearchStudentNumber {

    public List<Student> SearchStudentRecordReader(Student y) {
        String url = "jdbc:mysql://localhost:3306/";
        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 re = st.executeQuery("SELECT studentNo FROM bio");
            String mayaman = " ";
            String bringMe= " ";
            while (re.next()){
                Student myStudent = new Student();
                myStudent.setStudentNumber(re.getString("studentNo"));
                mayaman = myStudent.getStudentNumber();
                bringMe+=mayaman;
                System.out.println("sana: "+ myStudent.getStudentName());
            }
            for(int count= 0 ; count <=y.getSearchNo().length(); count++){
                String fake=Character.toString(y.getSearchNo().charAt(count));
                for(int count_sec = 1; count_sec<=bringMe.length() ; count_sec++){

                    String orig =Character.toString(bringMe.charAt(count_sec));
                    System.out.println("entered: "+Character.toString(y.getSearchNo().charAt(count)));
                    System.out.println("laman: "+Character.toString(bringMe.charAt(count_sec)));
                    if(Character.toString(y.getSearchNo().charAt(count)).equals(Character.toString(bringMe.charAt(count_sec)))){
                        System.out.println("Im IN!");
                        ResultSet res = st.executeQuery("SELECT * FROM  bio");

                        while (res.next()) {

                            Student myStudent = new Student();
                            myStudent.setStudentNumber(res.getString("studentNo"));
                            myStudent.setStudentName(res.getString("studentName"));
                            System.out.println("Name: "+myStudent.getStudentName());
                            myStudent.setCourse(res.getString("course"));
                            myStudent.setSYear(res.getString("syear"));

                            studentList.add(myStudent);

                        }

                    }else{
                        JOptionPane.showMessageDialog(null,"Sorry, there is no data to display!");
                    }
                    conn.close();
                    break;
                }


            }


        }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;
    }

}

thanks, hope you can help me!

your 'myStudent' doesn't "contain" null value, null indicates that your reference object doesn't reference anything, and is actually useless.
it means you haven instantiated that variable yet.
you'll have to check whether the initialization is reached.

looks like you did instantiate it, but we'll have to check the Student class to be sure what went wrong.

I have, it works fine before but when I created those two class above, i cant get the value from it.. this is what i should get , the name... etc:

package app.ui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
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.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 AddStudent {

    private JFrame frame;
    private JTextField txtStudentNumber;
    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 static void addNewStudent() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    AddStudent window = new AddStudent();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public AddStudent() {
        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 lblStudentNumber = new JLabel("Student Number: ");
        lblStudentNumber.setBounds(35, 23, 104, 23);
        frame.getContentPane().add(lblStudentNumber);

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

        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("Course:");
        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 btnAddStudent = new JButton("Add Student");
        btnAddStudent.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Student myStudent = setAddNewStudent();


                DataFileWriter myDataFileWriter = new DataFileWriter();
                myDataFileWriter.StudentRecordWriter(myStudent);

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


            }
        });
        btnAddStudent.setBounds(573, 322, 143, 23);
        frame.getContentPane().add(btnAddStudent);

        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.setStudentNumber(txtStudentNumber.getText());
        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{
            myStudent.setCivilStatus("Single");
            System.out.print(rbtnAddSingle.getText());
        }

    }


}

well, this is the line where it goes wrong:
String fake=Character.toString(y.getSearchNo().charAt(count));

with y being an instance of Student. but without seeing any of the code of Student, we won't be able to say much.
do you automatically generate a searchNo when you call the default constructor of Student?

nope, this is my myStudent class:

package app.model;

import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JTextField;

public class Student {

private String SearchNo;
    public String getSearchNo() {
    return SearchNo;
}
public void setSearchNo(String searchNo) {
    SearchNo = searchNo;
}
public String getBdayMoTalaga() {
    return bdayMoTalaga;
}
public void setBdayMoTalaga(String bdayMoTalaga) {
    this.bdayMoTalaga = bdayMoTalaga;
}
    private String StudentNumber;
    private String StudentName;
    private String Age;
    private String Gender;
    private String CivilStatus;
    private String BMonth;
    private String Bdday;
    private String BYear;
    private String bdayMoTalaga;
    public String bdayMoTalaga() {
        return bdayMoTalaga;
    }
    public void bdayMoTalaga(String bdayMoTalaga) {
        this.bdayMoTalaga = bdayMoTalaga;
    }
    private String ContactNumber;
    private String Religion;
    private String BPlace;
    private String Nationality;
    private String Address;
    private String Parent;
    private String Relation;
    private String Course;
    private String RContactNumber;
    private String Year;
    private String SYear;
    private String SchoolYear;
    private String Section;



    public String getStudentNumber() {
        return StudentNumber;
    }
    public void setStudentNumber(String studentNumber) {
        StudentNumber = studentNumber;
    }
    public String getStudentName() {
        return StudentName;
    }
    public void setStudentName(String studentName) {
        StudentName = studentName;
    }
    public String getAge() {
        return Age;
    }
    public void setAge(String age) {
        Age = age;
    }
    public String getGender() {
        return Gender;
    }
    public void setGender(String gender) {
        Gender = gender;
    }
    public String getCivilStatus() {
        return CivilStatus;
    }
    public void setCivilStatus(String civilStatus) {
        CivilStatus = civilStatus;
    }
    public String getBMonth() {
        return BMonth;
    }
    public void setBMonth(String bMonth) {
        BMonth = bMonth;
    }
    public String getBdday() {
        return Bdday;
    }
    public void setBdday(String bdday) {
        Bdday = bdday;
    }
    public String getBYear() {
        return BYear;
    }
    public void setBYear(String bYear) {
        BYear = bYear;
    }
    public String getContactNumber() {
        return ContactNumber;
    }
    public void setContactNumber(String contactNumber) {
        ContactNumber = contactNumber;
    }
    public String getReligion() {
        return Religion;
    }
    public void setReligion(String religion) {
        Religion = religion;
    }
    public String getBPlace() {
        return BPlace;
    }
    public void setBPlace(String bPlace) {
        BPlace = bPlace;
    }
    public String getNationality() {
        return Nationality;
    }
    public void setNationality(String nationality) {
        Nationality = nationality;
    }
    public String getAddress() {
        return Address;
    }
    public void setAddress(String address) {
        Address = address;
    }
    public String getParent() {
        return Parent;
    }
    public void setParent(String parent) {
        Parent = parent;
    }
    public String getRelation() {
        return Relation;
    }
    public void setRelation(String relation) {
        Relation = relation;
    }
    public String getRContactNumber() {
        return RContactNumber;
    }
    public void setRContactNumber(String rContactNumber) {
        RContactNumber = rContactNumber;
    }
    public String getYear() {
        return Year;
    }
    public void setYear(String year) {
        Year = year;
    }
    public String getSYear() {
        return SYear;
    }
    public void setSYear(String sYear) {
        SYear = sYear;
    }
    public String getSchoolYear() {
        return SchoolYear;
    }
    public void setSchoolYear(String schoolYear) {
        SchoolYear = schoolYear;
    }
    public String getSection() {
        return Section;
    }
    public void setSection(String section) {
        Section = section;
    }
    public String getCourse() {
        return Course;
    }
    public void setCourse(String course) {
        Course = course;
    }


}

I set all of this on my AddStudent class
except for set SearchNo, i set it in ListOfStudent class.

java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.charAt(Unknown Source)
at app.SearchByKey.SearchStudentNumber.SearchStudentRecordReader(SearchStudentNumber.java:38)

That's not a null reference. It's an attempt to get a char from a String that doesn't have enough characters in it. Specifically you are trying to acccess the second character (index number 1, the indexs are zero-based) when there is only one or zero characters in the String. That's because count has become greater than (length -1) in youyr loop.
Look at your loop termination condition on line 37. You use <=. Think about it.

yeah i changed it but my problem now is myStudent, :(

while (re.next()){
                Student myStudent = new Student();
                myStudent.setStudentNumber(re.getString("studentNo"));
                mayaman = myStudent.getStudentNumber();
                bringMe+=mayaman;
                System.out.println("sana: "+ myStudent.getStudentName());
            }

and this is what it prints:

sana: null
sana: null
sana: null
sana: null
sana: null
sana: null
sana: null
sana: null
sana: null
sana: null

That's in this code, yes?

 while (re.next()){
Student myStudent = new Student();
myStudent.setStudentNumber(re.getString("studentNo"));
mayaman = myStudent.getStudentNumber();
bringMe+=mayaman;
System.out.println("sana: "+ myStudent.getStudentName());
}

You create a new Student, set & get its sudentNumber, then get the studentName. There's nowhere you set the name, so it's null.

Ah! thank you!.. but i still have a problem regarding the looping can u explain to to me again? i changed it to this:

for(int count= 0 ; count <y.getSearchNo().length(); count++){
                String fake=Character.toString(y.getSearchNo().charAt(count));
                for(int count_sec = 1; count_sec<=bringMe.length() ; count_sec++){

                    String orig =Character.toString(bringMe.charAt(count_sec));
                    System.out.println("sana: "+ y.getSearchNo());
                    if(Character.toString(y.getSearchNo().charAt(count)).equals(Character.toString(bringMe.charAt(count_sec)))){
                        System.out.println("Im IN!");
                        ResultSet res = st.executeQuery("SELECT * FROM  bio");

                        while (res.next()) {

                            Student myStudent = new Student();
                            myStudent.setStudentNumber(res.getString("studentNo"));
                            myStudent.setStudentName(res.getString("studentName"));
                            System.out.println("Name: "+myStudent.getStudentName());
                            myStudent.setCourse(res.getString("course"));
                            myStudent.setSYear(res.getString("syear"));

                            studentList.add(myStudent);

                        }

                    }else{
                        JOptionPane.showMessageDialog(null,"Sorry, there is no data to display!");
                    }
                    conn.close();
                    break;
                }


            }

thank yoU!

i still have a problem regarding the looping can u explain to to me again?

Suppose the length is 3. The 3 characters are at index 0, 1, and 2 respectively.
if your loop is

for (int i = 0; i <= length; i++)
   ...charAt(i);

then you will execute the loop 4 times, with i = 0, 1, 2, and 3. On the last pass of the loop the charAt(3) will fail becuase there is no char at index 3.

Change it to i < length and now you just access characters 0, 1, and 2 - so that's OK.

changed it to this but it is still giving me an error:

for(int count= 0 ; count <y.getSearchNo().length(); count++){
                for(int count_sec = 1; count_sec<bringMe.length() ; count_sec++){

Sorry, I'm not a mind reader. I have no idea what error you are getting nor where it is happening.

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.