aspose file tools*
The moose likes JDBC and the fly likes Select query using Prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Select query using Prepared Statement" Watch "Select query using Prepared Statement" New topic
Author

Select query using Prepared Statement

Deva Devaa
Greenhorn

Joined: Jun 14, 2014
Posts: 11
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
Marshal

Joined: Mar 22, 2005
Posts: 42620
    
  65
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.


Ping & DNS - my free Android networking tools app
Deva Devaa
Greenhorn

Joined: Jun 14, 2014
Posts: 11
I am getting error in line no 86


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42620
    
  65
... but you won't tell us what the error is? Post the full stack trace.
Deva Devaa
Greenhorn

Joined: Jun 14, 2014
Posts: 11
error



You clicked the button
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at customer_details.actionPerformed(customer_details.java:85)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42620
    
  65
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

Joined: Jun 14, 2014
Posts: 11
I corrected My Code as:


Now Query is run successfully but the result it not show in the jtextfield
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42620
    
  65
Have you checked that all the records that you think should be returned by the query are in fact being returned by the query?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Select query using Prepared Statement