File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query select where

 
Mark Miranda
Greenhorn
Posts: 24
  • 0
  • 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
Pie
Posts: 20160
23
MySQL Database
  • 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
  • 0
  • 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
  • 0
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic