Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class UpdateExample {
- public static void main(String[] args) {
- Connection connection = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/student", "root", "");
- Statement statement = connection.createStatement();
- String sql = "UPDATE student_table SET name = 'Nguyen Van B' where student_code='SV2'";
- statement.executeUpdate(sql);
- System.out.println("DONE!");
- } catch (ClassNotFoundException | SQLException e) {
- System.err.println(e);
- } finally {
- if (connection != null)
- try {
- connection.close();
- } catch (SQLException e) {
- System.err.println(e);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement