File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "Problem with MySQL syntax" Watch "Problem with MySQL syntax" New topic

Problem with MySQL syntax

bat ken

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
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)

\\pass in parameter
<%if (rec_status.equals("R"))%>

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

Thank You
joe woods

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

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.


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.
I agree. Here's the link:
subject: Problem with MySQL syntax
It's not a secret anymore!