Please help with JSP mysql update query

Reply

Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Please help with JSP mysql update query

 
0
  #11
May 25th, 2008
in fact its only commonality with Javascript is that it's a mess (which it happens to have in common with php as well).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,628
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Please help with JSP mysql update query

 
0
  #12
May 26th, 2008
> Javascript is amazing, I didn't think you could touch mysql with it!

You can't, at least not with browser embedded Javascript. It's a different ball game altogether if you are using Server Side Javascript.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 9
Reputation: articles is an unknown quantity at this point 
Solved Threads: 0
articles articles is offline Offline
Newbie Poster

Re: Please help with JSP mysql update query

 
0
  #13
May 28th, 2008
The code you have written is correct... but java is a case sensitive language so might be there is some problem with the case..

check it carefully
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,426
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 258
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Please help with JSP mysql update query

 
0
  #14
May 28th, 2008
Originally Posted by articles View Post
The code you have written is correct... but java is a case sensitive language so might be there is some problem with the case..

check it carefully
To tell you the truth, the code is not correct. This line
  1. int UQ=statement.executeUpdate("insert into questions (qid, question, answer, subject) values ('," + questionin + "," + answerin + "," + subjectin + ")");
is definately false (and the cause of the sql error, as noted earlier). Where is the closing quote (') after the variable questionin? And why are there no quotes around any of the others?

All this would not be a problem if the OP would two things that she should always do, and should have done from the beginning (but she probably learned from tutorials on roseindia, they love pushing this dope), which are:

1) Use a PreparedStatement. Do not cobble together a Statement like this. It is error prone in the coding, error prone in the execution (what happens if one of the variables contains a quote (') itself), and wide open to SQL injection attacks.

2) Don't use scriplets. They only still exist for backwards compatability and it is strongly reccommended not to use them anymore.
Last edited by masijade; May 28th, 2008 at 9:31 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC