Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with MySQL syntax

 
bat ken
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I would like to retrieve email address from database, but I am not be able to get the value and store into my Sender. When I hardcode my email, it can send out the mail successfully, but when I use SQL to retrieve, it cannot run. Pls help...


\\Define Variable
<%String Tabcont="", dte="",Subject="", ln_num ="",remark="",pur="",in_desc_combine
="",mtr_cde
="",selectExceed1="",seqDftran="",Body="";
String Rej="";
double qty=0;
String emailadd="", Sender="",Recipient="";%>

\\SQL query
String emailaddSender=" SELECT em_email_addr FROM emmast "+
" WHERE em_name = '"+ whoReject+"' ";
ResultSet emSender = null;
try {emSender = db.execSQL(emailaddSender);}
catch (SQLException e)
{System.err.println("Error-123");}
if(emSender.next()){
Sender=emSender.getString("em_email_addr");}

\\pass in parameter
checkstatus();
{
<%if (rec_status.equals("R"))%>
<%{%>
<%send.sending(SMTPServer,Sender,Recipient,CcRecipient,BccRecipient,Subject,Body,Attachments);%>
<%}%>
}

**I am not sure what is the mistake I did in my sql query, please help

Thank You
 
joe woods
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you like to paste the code in a good format?thank you
[ February 26, 2006: Message edited by: Bear Bibeault ]
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Its a bad idea to put your logic in a JSP like this - it makes your code difficult to read and maintain.

Rather put it into a utility class - at the moment you are opening up yourself to all sort of problems that can occur due to a misplaced key stroke.

Im not answering your questio here but while you are doing this you might find the problem anyway.

Chris
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post the exception you get?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic