One, the code is as follows
private void Deletemysql () {//TODO auto-generated method stubjava.sql.Statement sm= null;java.sql.connection cn = NULL; ResultSet rs = null;try {//Load driver Class.forName ("Com.mysql.jdbc.Driver"). newinstance ();//Get Connected CN = Drivermanager.getconnection ("Jdbc:mysql://localhost:3306/learn?user=root&password=&useunicode=true &characterencoding=utf8 "); sm= cn.createstatement (); int i= sm.executeupdate (" Delete from user where username= ' 332 ' "); System.out.println (i); if (I >= 1) {System.out.println ("Delete: Success");} else {System.out.println ("Delete: Failed");}} catch (Exception e) {//TODO auto-generated catch Blocke.printstacktrace ();} finally {try {if (SM! = null) {Sm.close ()} if (CN = null) {Cn.close ();}} catch (SQLException e) {e.printstacktrace ();}}}
MySQL database __jdbc direct Operation __statement__delete