How can i pass valid email address as a prarameter value in sql query
sudheer yathagiri kumar
Ranch Hand
Joined: Mar 22, 2011
Posts: 31
posted
0
hi to all,
MembersTable -- this is dbtable contails Email,name,pan etc fields.
1)before passing email as a parameter to the query i validate the email address.And store that value in one string say emailidvalue,
2)rs=st.executeQuery
("select Name,Email from MembersTable where Email like '"+emailidvalue+"' ");
it is not working am i doing in right path..
please help me
thanks in advance.
first of all thanks for repling my post,
actually my requirment is setting email value dynamically.
first i am trying to do in static manar that is i am fixing the email value as String se="sudheer@ca.com"; This is "se" value may sent to the query as a paramater value.
In database also Email is stored like this only(sudheer@ca.com)
query is :
rs=("select Name,Email from MembersTable where Email like '"+se+"' ");
out put : nothing will come .
is it use any regular expression related values in the query please help me ..
thanks in advance..
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35224
7
posted
0
For starters, use PreparedStatement. Cobbling together SQL statements with string concatenation is fraught with problems.
Secondly, does "se" contain percentage signs? If not, using "like" provides no benefit except to slow down the query, and you should use "=" instead.
Lastly, if a query doesn't return the results you expect, I'd start by running it directly against the DB (with whatever command-line or GUI tool you usually use to interact with the DB).