package org.dml;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class UpdateDemo {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static final String user = "root";
public static final String password = "root";
public static void main(String[] args) throws Exception{
Connection conn = null;
Statement stmt = null;
Class.forName(DBDRIVER);
String sql = "update user set name = 'chenfeipeng'," +
"password='hello',age=22,sex='女' where id = 4;";
conn = DriverManager.getConnection(DBURL, user, password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class UpdateDemo {
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";
public static final String user = "root";
public static final String password = "root";
public static void main(String[] args) throws Exception{
Connection conn = null;
Statement stmt = null;
Class.forName(DBDRIVER);
String sql = "update user set name = 'chenfeipeng'," +
"password='hello',age=22,sex='女' where id = 4;";
conn = DriverManager.getConnection(DBURL, user, password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
}