• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

execute method in SQl

 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all

i am trying to create a login form
in which i take user name ,email id and password.
if the user is registered user the name ,id and password
are stored into database in table.So when the user logs in
i wanted to check by traversing through the database
that the name and password are right so previuosly
i was using
ResultSet rs;
rs.next(); method so it traverses
through all the registered name in database
but i felt this as abit long
so i choose execute () method which returns boolean value
if it gets the exact name and password but

below is my method



each time the query gets executed
if the user is not registered ie user name is not present
in the database then also i am getting value of b=true
whereas i expect if user name and password is not present
it must give b=false.


i dont know where i am going wrong ?

may be the method which i have used is not appropriate
for use at this place.........


Anyone can help me on to what i must use
or where i am going wrong it will be realy great
thanks in advance.............

Dhwani:>Its always too soon to quit.
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dhwani As per java-docs


boolean execute(String sql)throws SQLException

Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results



therefore if your query is executed successfully then It will definitely return a resultset.

If there are no matching rows as per given criteria resultset.next() will be false. That is why you get true every time.

you modify your code
as





Thanks,
Shailesh
[ February 04, 2008: Message edited by: Shailesh Chandra ]
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi shailesh!!!

Thanks for such a great reponse

i modified the query as shown by you as below

but i am stuck now somewhere else



i am storing this values when the user registers
in a table ,and when the user logs in the name and password is getting
verified in my query above
when i use statement as


but i want to verify not only name before logging in
but also password so i used query as


any help on the above will be
realy great

thanks in advance!!

Dhwani:>Winning is not important but it is the only thing.
[ February 04, 2008: Message edited by: dhwani mathur ]
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
  • Check the case-sensitivity of the password
  • user out.println to print your query, which is formed by code, and execute same or sql console


  • dhwani,

    validate above mentioned steps


    Thanks,
    Shailesh
     
    dhwani mathur
    Ranch Hand
    Posts: 621
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi shailesh!!

    Thanks a lot
    my problem is solved......


    Dhwani:>Winning is not important but it is the only thing.
    [ February 06, 2008: Message edited by: dhwani mathur ]
     
    Shailesh Chandra
    Ranch Hand
    Posts: 1087
    Oracle Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    glad to know that its working now


    Thanks,
    Shailesh
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic