Created
June 19, 2021 04:01
-
-
Save extsalt/5c88277d88d16b6bcd9279bd15a13e13 to your computer and use it in GitHub Desktop.
Update 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 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 updateRecord = connection.prepareStatement( | |
"update students set email = ? where id = ?" | |
); | |
updateRecord.setString(1, "kmgupta822000@gmail.com"); | |
updateRecord.setInt(2, 6); | |
updateRecord.execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment