Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:07:57+00:00 2026-06-15T11:07:57+00:00

Getting a NullPointerException when calling method fillDBWeek(String mName). I can not spot where I

  • 0

Getting a NullPointerException when calling method fillDBWeek(String mName). I can not spot where I am going wrong can some one please help me?

This is the error I am getting for the following method

*Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at View.LectureReport.fillDBWeek(LectureReport.java:49)
    at View.LectureReport$2.actionPerformed(LectureReport.java:96)*

Method fillDBWeek

public void fillDBWeek(String mName)
    {
         tableModel.setDataVector(lRHand.popuSDataWeek(mName), columnNames);
         table.setModel(tableModel);
         table.repaint(); 
    }

Where the method is called when pressing button

JButton btnViewReport = new JButton("View Report");
    btnViewReport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String moduleName = (String)comboBox.getSelectedItem();
            if(comboBox_1.getSelectedItem().equals("Week"))
            {
                fillDBWeek(moduleName);
            }
            else if (comboBox_1.getSelectedItem().equals("Semester"))
            {
                fillDBSem(moduleName);
            }
            else if (comboBox_1.getSelectedItem().equals("Year"))
            {
                fillDBYear(moduleName);
            }
        }
    });

Query using to call the data from SQL database

public Object[][] popuSDataWeek(String moduleName)
{
    data = new Object[30][9];

    try{
           Class.forName(DRIVER_CLASS);

            connection = DriverManager.getConnection( url,"polk", "mire");

            statement = connection.createStatement();
            results = statement.executeQuery("SELECT * FROM Group6_StudAttWeek WHERE module = '"+ moduleName +"'");
            int i=0;
            while(results.next())
            {
            data[i][0]= results.getString("firstname");
            data[i][1]= results.getString("lastname");
            data[i][2]= results.getString("module");
            data[i][3] = results.getString("yearOfStudy");
            data[i][4]= results.getInt("workshop%");
            data[i][5]= results.getInt("tutorial%");
            data[i][6] = results.getInt("lecture%");
            data[i][7] = results.getInt("avg%");
            data[i][8] = results.getInt("number");
            i++;
            }
       results.close();
       statement.close();
       connection.close();
       } catch (SQLException sqlException) {
       sqlException.printStackTrace();
       System.exit(1);
       }catch(Exception exception) {
       System.err.println("An error happened");
       System.exit(1);
       }

    return data;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:07:59+00:00Added an answer on June 15, 2026 at 11:07 am

    Based on the stack:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at View.LectureReport.fillDBWeek(LectureReport.java:49)
        at View.LectureReport$2.actionPerformed(LectureReport.java:96)
    

    The exception rises in fillDBWeek, either because tableModel or table are null. If the exception is thrown by popuSDataWeek, instead, it should be present on the stacktrace, but anyway the only probable null object I see is connection.

    Please, make sure the proper objects are declared and initialized before using them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im not sure why im getting NullPointerException. The method getQuestion() currently points to a
i am writing code for btree algorithms. i am getting NullPointerException . why???? please
I am getting NullPointerException on lv.setAdapter(adapter) . I don't understand, I changed some codes
I am parsing the xml file. I am always getting NullPointerException . Can anyone
I am getting nullpointerexception when trying to reach my activity and change some ints.
I am getting NullPointerException in the following code : private Map<String,List<Entry>> Days; private void
I have a about screen that has some buttons, but I keep getting NullPointerException
i keep getting NullPointerException on this line: SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this); i ran some
I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in
I'm getting NullPointerException :s when using sstable2json in Cassandra 0.6.0-beta3: $ bin/sstable2json .../cassandra/data/system/LocationInfo-1-Data.db Exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.