Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select query using Prepared Statement

 
Deva Devaa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know what is wrong in my code. Following are the conditions in my code given below:

I will enter the customer id in the jTextField
After Entering the customer id then in the Database it will search relative information of that customer id (customer_id,customer_name,customer_contact).
After Collecting relative information of that particular customer id, it will display on the jTextField.
These is my code given below:

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What, exactly, does the code do now, and how is that different from what you were expecting it to do? At which point does the code's behavior start to deviate from your expectation?

Is the actionPerformed method ever being called? Is the "try" block in line 75 ever being executed? Also, you should print out the full stack trace in the catch handler in line 102. Currently the code discards all information that would help you debug this issue.
 
Deva Devaa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting error in line no 86


 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... but you won't tell us what the error is? Post the full stack trace.
 
Deva Devaa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error



You clicked the button
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at customer_details.actionPerformed(customer_details.java:85)
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So which object is null? My guess is it's "rs1", because the code you posted never assigns something other than "null" to it.
 
Deva Devaa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I corrected My Code as:


Now Query is run successfully but the result it not show in the jtextfield
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked that all the records that you think should be returned by the query are in fact being returned by the query?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic