0

everyone. I have recently started Java programming.

I am trying to make a school management system. In there, I received some error while entering marks in the report card section. I am not sure where I went wrong as the program compiles successfully. However, while clicking on save button, I am getting this error:

java.lang.NullPointerException: Cannot invoke "String.toString()" because the return value of "javax.swing.JTextField.getSelectedText()" is null

Here is what I have tried:

CODE

And Here is my MYSQL database:

MYSQL DATABASE_1

MYSQL DATABASE_2

I will be really grateful for help/tip you can give me. Thank you!!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 2
    Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – OH GOD SPIDERS Nov 18 '21 at 10:58
  • 1
    Hello and welcome. Please include a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve) of your code directly in the question, not as an external link or as a picture. Then you can link to your code on external service, but most of what's needed to answer the question should be included in the question itself. – Federico klez Culloca Nov 18 '21 at 10:59
  • Yes, I saw that. But unfortunately, I am still not able to solve the problem. The program compiles successfully, however I get a message saying "insertion failed" and "java.lang.NullPointerException: Cannot invoke "String.toString()" because the return value of "javax.swing.JTextField.getSelectedText()" is null" – Devanshu Mahapatra Nov 18 '21 at 11:01
  • please read https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question and edit your question – nbk Nov 18 '21 at 11:03
  • *"Yes, I saw that."* You saw what? The Q&A on the NPE? The page on the MRE? *SPIDERS?* Tip: Add @OHGODSPIDERS (or whoever, the `@` is important) to *notify* a person of a new comment. – Andrew Thompson Nov 18 '21 at 11:46
  • Questions should be self-contained. Don't post code on external sites, put it in the question itself. – Mark Rotteveel Nov 18 '21 at 12:34

0 Answers0