• 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

Why executeQuery() doesnt work?

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

Hi friends.
I want to create web page . In login page i want create sessions for users and admin. But i have error. My query doesnt give result. rslt.next() is not true

 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should not be in a JSP page.
At the least it should be in a servlet.

Log the SQL string used (you might want to move that into a separate SQL String variable).
That way you'll see what query is being run.

Also, that's not a PreparedStatement.
There's no binding of variables done in it.

Finally I would suggest giving the user a role, rather than checking the username.  You also don't need to recheck the password.  You already know it's correct.

Oh yes, just noticed, you're not closing your resources, either by using a try-with-resources, or in a finally block.
 
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Besides the points that Dave made, I want to emphasize how important it is to use prepared statements correctly. Right now, you're putting user supplied information directly in your query.

Please explain to us what will happen if I pass the following uname in the request:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic