This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Need help to solve JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need help to solve JDBC problem" Watch "Need help to solve JDBC problem" New topic
Author

Need help to solve JDBC problem

Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Greetings everyone,
Please do not be put off by the length of this question, it's quite easy to follow and understand, I assure you..........
I am developing this appliation that uses JDBC_ODBC and I am getting an exception querying the database using this application if I try to look up the contents of 2 columns. It only works when I try to look up one column.
Here's some of the code:
First there's this the GUI that accepts user inputs and then passes it on to the JDBC application.

And then the part of the JDBC application that uses what's passed into the constructor of the DisplayDetails class.

All works fine this way. But when I pass in the two entered values into the constructor (which sould really be the case), problems arise.
When at the bottom of the CustomerValidation.java constructor, the two values that are supposed to be passed are passed into the constructor of DisplayDetails.java, are pssed like this:

and in display details, you have:

How can I eliminate this exception and get this application to work the way it should?
I should also add that the database is in MS Access and the first two columns are the PinNumber and AccNo.The AccNo column is the primary key in the database.
Any useful suggestions would be welcome.
Thanks.


SCJP
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
Hi there,
look at the following line from your example...
ResultSet resultSet = statement.executeQuery("SELECT * FROM Customers WHERE AccNo="+ userAccNo + "AND PinNumber= "+pin );

I think the error is because you are missing a space before the 'AND'

should be :

try that.
chris


SCJP 1.2, SCJP 5, SCBCD
Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Thanks so much Chris .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need help to solve JDBC problem