Hello,
I am using the following simple connection inside a servlet to update data in MySQL:
try { //SETUP THE CONNECTION TO MYSQL Statement stmt; String MySQLUrl = "jdbc:mysql://localhost:3306/somedb"; Connection con = DriverManager.getConnection(MySQLUrl,"user","password"); Debug.print("MySQLUrl = " + MySQLUrl + " AND con = " + con); stmt = con.createStatement(); //CREATE THE UPDATE QUERY SYNTAX String query = "UPDATE db.tablename SET fieldname = " + NewCtc + " WHERE db.tablename.anotherfield = " + strValue + " AND db.tablename.athirdfield = " + strValue2 + " AND db.tablename.afourthfield = " + strValue3; //EXECUTE THE UPDATE SQL con.setAutoCommit(false); stmt.executeUpdate(query); con.commit(); con.close(); } catch(Exception e) { e.printStackTrace(); Debug.print("ERROR in updating my field"); ResponseType="ERRORUpdatingMyField"; PrintWriter out = response.getWriter(); out.print("|ResponseType=" + ResponseType); }