wood burning stoves 2.0*
The moose likes JDBC and the fly likes SQL commands in MS-Access....Pls Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL commands in MS-Access....Pls Help" Watch "SQL commands in MS-Access....Pls Help" New topic

SQL commands in MS-Access....Pls Help

suhail sarwar

Joined: Mar 15, 2003
Posts: 4
I have the following sql statement in my program:

This statement works as it will pick out the account numbers from the database. BUT when I input an account number that does not exist in the database it does not give me a SQLException, it just sits there !
Anyone have any ideas as to how I can tell the program that if it does not find the account number it should display a message ??
Any help appreciated,
[ March 15, 2003: Message edited by: suhail sarwar ]
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Hi Sarwar,
With all of the databases that I have worked with, when you execute a database query that does not return any rows, it is not an error (and therefore does not give an "SQLException").
The "next()" method (in "java.sql.ResultSet") returns 'false' if there are no more rows in the result set. For an empty result set (i.e. a query that returns no rows), the first invocation of "next()" will return 'false', example:

Hope this helps you.
Good Luck,
suhail sarwar

Joined: Mar 15, 2003
Posts: 4
yes you are right.I've got it working now thanks for your help.
It is sorta covered in the JavaRanch Style Guide.
subject: SQL commands in MS-Access....Pls Help
Similar Threads
Using transaction processing (commit())
Problem in Threading
query to find database..
Thread - Niko'Blog Question-58 Confusion
JDBC with MS SQL Server 2000