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

query select where

 
Mark Miranda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to using JDBC and for making a query select.... WHERE column = variable

how do you format the select statement?

this is what I have and the query doesn't work.


 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't do it that way. Use a PreparedStatement which uses parametrized queries instead. Like this:


That's assuming that your employee_id column is actually declared as a text column in the database and not a numeric column.
 
Mark Miranda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Don't do it that way. Use a PreparedStatement which uses parametrized queries instead. Like this:


That's assuming that your employee_id column is actually declared as a text column in the database and not a numeric column.


That make sense. thanks!
 
Patrick de Kruijf
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanted to say thanks, I couldn't get my query working the whole evening, but now it works!

Cheers,

Patrick
 
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!