| Author |
Getting 'null' value in response to statement.executeUpdate method
|
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
Hello,
I am trying to insert few records in to mysql database. As i can successfully able to establish connection with server but not able to insert a single record through net beans ide gui interface or front end.
The code which i wrote for connection is encapsulated in Constructor method and in event handler i have written code to insert data. this code is as follows:
in this it throws an exception error and "r" yields null. I am confused where the hell i have made mistake that it is giving me null as output instead of 0 or 1.
Thank you!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
|
Could you please post the exception message, if any, and exception type?
|
Bye,
Nicola
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
Hi..!!
actually i wrote these code in try -catch block, so it is not generating much verbose however as i have use stack trace method it generates following messaga: Ljava.lang.StackTraceElement;@d49271
Thank you for quick response.!!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
Nikhil B. Singh wrote:Hi..!!
actually i wrote these code in try -catch block, so it is not generating much verbose however as i have use stack trace method it generates following messaga: Ljava.lang.StackTraceElement;@d49271
Thank you for quick response.!!

If you can't debug your code just add after line 53:
And see what is printed on your output. You should see the exception type, and probably where exactly it has been generated.
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
.
.
.
If you can't debug your code just add after line 53:
And see what is printed on your output. You should see the exception type, and probably where exactly it has been generated.
I am sorry, i could not get understand much from this, if you don't mind, would you please help me to catch the error source.
Thank you!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
Nikhil B. Singh wrote:Hi..!!
actually i wrote these code in try -catch block, so it is not generating much verbose however as i have use stack trace method it generates following messaga: Ljava.lang.StackTraceElement;@d49271
Thank you for quick response.!!

Anyway
getStackTrace() method returns an array of StackTraceElement.
So it's useless to print it out or use it as a message for a message Panel.
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
Much more clearer now
See your class StudentInformation.java at line 327.
What are you doing there? What instructions are you trying to execute?
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
at line 327: I am writing code to get a value from radio button. I have two radio button controls and trying to read the selected one value.
Please let me know if I am writing wrong syntax to read the value of selected radio button.
Thank you!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
Ok either radion button rbtn_indiv is null or rbtn_indiv.getName() is null.
did you make somewhere before line 327
rbtn_indiv = new JRadioButton(..) ?
Did you set the name of your JRadioButton?
That's the heart of your problem
Let me know if you want.
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
Hi..
As you have suggested I examined that radio button code again, as generated in Net beans ide auto code generated section..
I have set the name property as i have given in radio button's text property field.
However, i am facing new kind of error, which is as follows
Uncompilable source code - variable team_t might not have been initialized.
I think, i m not reading value of selected radio button properly. Please throw some light to do perform this.
Thank you !!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
Nikhil B. Singh wrote:Hi..
As you have suggested I examined that radio button code again, as generated in Net beans ide auto code generated section..
I have set the name property as i have given in radio button's text property field.
However, i am facing new kind of error, which is as follows
Uncompilable source code - variable team_t might not have been initialized.
I think, i m not reading value of selected radio button properly. Please throw some light to do perform this.
Thank you !!
You must assign a value to every local variable.
So give team_t an initial value
for example:
In the code above you are always giving to String team_t the value "Individual"
Why?
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
Hi..
actually i have wrote that text mistakenly. however i have improved this mistake but the code i have written here to get the value of selected radio button is not working properly. this is why it is giving null pointer exception error.
I am confused that why these people have given Label & Name property associated with any swing component. It doesn't make any sense to set Text property and Label property separately.
plus i could not resolve this when we should use getText or getSelectedObjects method for radio button or which may be appropriate for radio button to identify selected radio button.
Thanks!!
|
 |
Nikhil B. Singh
Greenhorn
Joined: May 20, 2012
Posts: 18
|
|
Hi..
I have figured out the solution to read the value of selected radio button.
it is as follows:
Thank you very much for your kind support...!
With regards!
Nikhil!
|
 |
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
|
|
For future doubts you may refer to java tutorial
http://docs.oracle.com/javase/tutorial/uiswing/components/button.html
Bye,
Nicola
|
 |
 |
|
|
subject: Getting 'null' value in response to statement.executeUpdate method
|
|
|