Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Why executeQuery() doesnt work?

Ranch Hand
Posts: 32
  • 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. is not true

Master Rancher
Posts: 4669
  • 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.
Saloon Keeper
Posts: 12275
  • 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:
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic