You've committed 2 offences against good Enterprise Java practices.
First, you directly acquired your database connection from the DriverManager instead of using a Connection Pool. That's forgiveable while you're still learning, but it's inefficient and discouraged for real-world programming.
More seriously, you put your logic in the JSP using scriptlets. This will cause the Bear to growl at you.
Scriptlet use is discouraged these days. Among the reasons why it's discourages, you've already seen.There's virtually no way to put a breakpoint into scriptlet code and debug it.
Instead you should be using a Java servlet (Controller) to do your database logic and have it forward the results as bean objects for the JSP to display. Servlets are much easier to debug.
An IDE is no substitute for an Intelligent Developer.
Okay. Clearly you know how to write a PreparedStatement, so why are you still generating the SQL with String concatenation? I'd suggest it would be better like this:
And then, there isn't much point in setting the "fulname" column to the same value which is already there. So let's leave that out:
And finally we come to the main problem. I assume "the update failed" was accompanied by an error message, with more information, thrown by the JSP? If not, then that just means that it would be better to test this kind of code outside of the web application, or to arrange things so that you get to see the actual error message from the database server. Which would have told you that the SQL statement wasn't valid SQL. In your case you forgot to separate the parts of the "SET" clause with commas, as required by SQL. Thus:
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java