• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i pass valid email address as a prarameter value in sql query

 
sudheer yathagiri kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error are you getting. elaborate it further.
 
sudheer yathagiri kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic