import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class Jdbc {
public static void main(String[] args) throws Exception {
String url = "jdbc:mysql://localhost:3306/bank";
String username = "root";
String password = "123456";
Connection conn = DriverManager.getConnection(url,username,password);
String sql = "update stu set id = 1 where name = '馬運'";
Statement stmt = conn.createStatement();
int count = stmt.executeUpdate(sql);
System.out.println(count);
stmt.close();
conn.close();
}
}
我出錯的地方,一個是把表的名字寫到了資料庫該寫的地方,還有就是SQL語句的正確使用