Can someone help me, I was getting an error message about SQL syntax, now I get no error message, it redirects, but database does not change. I also made sure autocommit was enabled.
Any ideas?
<%@page import="java.sql.*,java.util.*" %>
<%
Connection conn = null;
PreparedStatement stmt = null;
String userName = "xxxx";
String password = "xxxx";
String host = "xxxx";
String port = "3306";
String db = "jobops";
String url = "jdbc:mysql://" + host + ":" + port + "/" + db;
try
{
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
String sql = "UPDATE ops SET " +
"firstname=?" +
",lastname=?" +
",comments=? " +
" WHERE id=" + request.getParameter("'id';");
stmt = conn.prepareStatement(sql);
stmt.setString(1,request.getParameter("firstname"));
stmt.setString(2,request.getParameter("lastname"));
stmt.setString(3,request.getParameter("comments"));
out.println("still here?");
out.println("no loop.");
stmt.executeUpdate();
response.sendRedirect("../list.jsp");
}
catch (Exception e)
{
out.println(e.getMessage());
}
finally
{
if (stmt != null) {
try {
stmt.close ();
}
catch (Exception e) { /* ignore close errors */ }
}
if (conn != null) {
try {
conn.close ();
}
catch (Exception e) { /* ignore close errors */ }
}
}
//
%>