Skip to content

Instantly share code, notes, and snippets.

@extsalt
Created June 19, 2021 04:04
Show Gist options
  • Save extsalt/e356a7e732bb771fe2ea4dfb9ef88f9c to your computer and use it in GitHub Desktop.
Save extsalt/e356a7e732bb771fe2ea4dfb9ef88f9c to your computer and use it in GitHub Desktop.
Delete Record
import jdk.jshell.spi.SPIResolutionException;
import java.sql.*;
public class Main {
public static void main(String... args) throws ClassNotFoundException, SQLException {
Connection connection = null;
//Loading of driver
Class.forName("com.mysql.cj.jdbc.Driver");
// Getting connection from driver
connection = DriverManager.getConnection("jdbc:mysql://localhost/srgp?user=root&password=");
PreparedStatement deleteRecord = connection.prepareStatement(
"delete from students where id = ?"
);
deleteRecord.setInt(1, 6);
deleteRecord.execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment