File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Need help to solve JDBC problem" Watch "Need help to solve JDBC problem" New topic

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 constructor, the two values that are supposed to be passed are passed into the constructor of, 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.

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.

Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Thanks so much Chris .
I agree. Here's the link:
subject: Need help to solve JDBC problem
It's not a secret anymore!