• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Why executeQuery() doesnt work?  RSS feed

 
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
  • 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: 3757
40
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Bartender
Posts: 9495
184
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!