Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

With out using resultset..?

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all

Is is possible to know where the record exists in DataBase for a preticular condition with out using Result set object
For Ex:- iwant to check the userid in database so that i will check in database and using result set i will forward my logic .
 
Jan Cumps
Bartender
Posts: 2618
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ResultSet is the interface to retrieve answers from your database.
Is there a reason why you can't use it for this purpose?
 
Tim Holloway
Bartender
Posts: 18467
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santhosh, you might want to get someone to help you to phrase that question a little more understandably.

I think what you're trying to do is the common case where you want to see if a user is defined in a database, but you do not actually want to retrieve any of the user data. The SQL version of that would be:


Or, if you're doing a login check:


These queries do return a result set, but it has only one row and one column, and its value is either 1 (user exists, password valid) or 0 (user does not exist, or password is invalid).

So, while you need a ResultSet, the logic isn't all that complicated and the overhead is pretty low:


This code won't execute - I've done some simplifications to illustrate the concept, but it's basically how you'd do something like that.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!