Skip to content

Instantly share code, notes, and snippets.

@extsalt
Created June 19, 2021 04:01
Show Gist options
  • Save extsalt/5c88277d88d16b6bcd9279bd15a13e13 to your computer and use it in GitHub Desktop.
Save extsalt/5c88277d88d16b6bcd9279bd15a13e13 to your computer and use it in GitHub Desktop.
Update Record
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