wood burning stoves 2.0*
The moose likes JDBC and the fly likes Problem with MySQL syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with MySQL syntax" Watch "Problem with MySQL syntax" New topic
Author

Problem with MySQL syntax

bat ken
Greenhorn

Joined: Dec 28, 2005
Posts: 24
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

Joined: Dec 08, 2005
Posts: 5
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

Joined: May 22, 2003
Posts: 108
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


SCJP 1.2, SCJP 5, SCBCD
vivien siu
Ranch Hand

Joined: Nov 10, 2005
Posts: 143
can you post the exception you get?


I'm not available, my BF's name is WORK.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem with MySQL syntax