Created
June 19, 2021 04:04
-
-
Save extsalt/e356a7e732bb771fe2ea4dfb9ef88f9c to your computer and use it in GitHub Desktop.
Delete Record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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