【问题标题】:How to Edit/Delete Data in MySQL database using servlet如何使用 servlet 编辑/删除 MySQL 数据库中的数据
【发布时间】:2012-03-23 16:12:01
【问题描述】:

如果我们要在数据库中添加新数据,我们使用类似这样的东西

            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(
                    "jdbc:mysql://mysql.cityu.edu.hk:3306/", "yyy", "xxx");
            stmt = con.createStatement();
            stmt.execute("USE yyy");
            id = (String) request.getParameter("id");
            text = (String) request.getParameter("text");
            time = (String) request.getParameter("time");
            query="insert into Table values(0,'" + id + "', 'ABC' ,'" + text + "','" + time + "');";
            int rs = stmt.executeUpdate(query);

但是如果我们要编辑/删除数据库中的某些内容呢?任何教程?非常感谢!干杯!

【问题讨论】:

    标签: mysql database servlets


    【解决方案1】:

    查看mysql手册了解updatedelete的语法。

    update table set column=value where id=rowID
    delete from table where id=rowID
    

    【讨论】:

      猜你喜欢
      • 2012-05-30
      • 2020-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2013-12-17
      相关资源
      最近更新 更多