Thursday, 3 April 2025

Write a Java Program to delete details of students whose initial character of their name is ‘A’.

  

 import java.sql.*;

 

class Students {

 

     public static void main(String args[]) throws Exception{

 

        Connection con;

        Statement stmt;

        Class.forName("com.mysql.jdbc.Driver");

          con =  DriverManager.getConnection("jdbc:mysql://localhost:3307/mca", "root", "");

 

         stmt = con.createStatement();

 

        int n = stmt.executeUpdate("delete from student where sname like 'A%'");

 

        System.out.println(n + " rows deleted..");

 

        con.close();

 

    }}