How to delete a record using JDBC

//Delete operation according to student id
    public void deleteOne(int id) {
        Statement stmt=null; //Send SQL statement and return execution result
        try {
            
            strSql="delete from student where id= "+id; //Deleted SQL statement
            stmt=conn.createStatement(); //Connect to database, submit SQL statement
            //Execute SQL
            stmt.executeUpdate(strSql);
            System.out.println("Delete data successfully"+strSql);
            
        } catch (Exception e) {
            / / TODO: handle exception
            e.printStackTrace();
        }
    }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324844283&siteId=291194637