How to do an mysql query using clausule where.?
Fore example:
SELECT id FROM user_ where userName="variable";
i think that in order to integrate an variable into the query select, i have to do something like this:
SELECT id FROM user_ where userName='$(variable)';
And , another question , one time, i have the correct query , in a connector , ¿what i have to do , in order to recieve the results?
i believe , that if i want to recieve the list data , i have to create an java.until.list variable, but if i need to recieve an numeric data , how i can to do it?
If i have any mistake , please correct me.
Regards
Question 1: what is wrong with my query?
instead of
SELECT id FROM user_ where userName='$(variable)';
you need
SELECT id FROM user_ where userName='${variable}'; //curly brackets
Question 2: how to translate resultset to List
I did a quick search on google and found this:
while(resultSet.next()) {
nameList.add(resultSet.getString("name"));
}
you should add this code to the final step of the connector, obviously changing it as necessary for Integers as you asked
regards
Comments
Thanks for reply ,
i have created an java.lang.long variable , in order to save the results of my mysql query, so , how i change the code that you gave me , in order to recieve java.lang.log data type , because this variable , i will put it in an actor filter .
an other question :
in your code there are , the line : getString("name").
what does it mean , it could be that i have to put the column name that i have in user_ table? , if is so, i have to put "id", because i have to retrieve the id of user that i put in clausule where
regards
hi ,
i want to save the result into java.lang.long variable.
regards