title: how insert value into sql sever using java?
body: <p>sorry if my questions are identical. I was trying to find out online documentation but I still have not solved the problem. it's an error in the line "stmt.executeUpdate ();"</p>
  
  <pre><code>public class DBConnect {
      private List&lt;SinhVien&gt; result = new ArrayList&lt;SinhVien&gt;();
  public void updateSQL(String masv, String malop, String ten,
              Date ngaysinh, String diachi) {
      try{
              Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
              Connection connection = DriverManager.getConnection("jdbc:sqlserver://MyPC:1433;databasename=QLSV;username=sa;password=APASSWORD");         
              PreparedStatement stmt = connection.prepareStatement("INSERT INTO SinhVien(masv, malop, ten, ngaysinh, diachi) VALUES(?, ?, ?, ?, ?");
              stmt.setString(1, masv);
              stmt.setString(2, malop);
              stmt.setString(3, ten);
              stmt.setDate(4, ngaysinh);
              stmt.setString(5, diachi);          
              stmt.executeUpdate();
      }
      catch(Exception e){
          e.printStackTrace();
      }       
      }
      public static void main(String[] args) {
          DBConnect dbConnect = new DBConnect();
          dbConnect.XuatDSSV();
          dbConnect.findSinhvienById("51003146");
          dbConnect.updateSQL("123", "malop", "ten", null, "diachi");
  
      }
  </code></pre>