đây là đoạn code thêm dữ liệu của mình
Mã:
private void btThemActionPerformed(java.awt.event.ActionEvent evt) { String kt=""; if(txtMHS.equals(kt)||txtTENHS.equals(kt)) { JOptionPane.showMessageDialog(null, "Không đủ dữ liệu vui lòng nhập lại!"); } else { try { Statement a = cn.createStatement(); String sql="Insert into hocsinh values('"+txtMHS.getText()+txtTENHS.getText()+"')"; int i = a.executeUpdate(sql); String sql2 = "select * from hocsinh"; PreparedStatement se = null; try { se = cn.prepareStatement(sql2); } catch (SQLException ex) { Logger.getLogger(Thhongtinhocsinh.class.getName()).log(Level.SEVERE, null, ex); } try (ResultSet re = se.executeQuery()) { Title.addElement("Ma hoc sinh"); Title.addElement("Ten hoc sinh"); DefaultTableModel defaut=new DefaultTableModel(Title,0); while(re.next()){ Row=new Vector(); Row.addElement(re.getString("Mahs")); Row.addElement(re.getString("Tenhs")); //Row.addElement(rs.getString("Diachi")); // Row.addElement(rs.getFloat("Diem")); defaut.addRow(Row); JOptionPane.showMessageDialog(null, "them thanh cong !"); } jTable1.setModel(defaut); } } catch (SQLException ex) { Logger.getLogger(Thhongtinhocsinh.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null,"them that bai"); } } }
đây là lỗi sau khi mình run chương trình
java.sql.SQLException: Column count doesn't match value count at row 1
bạn nào biết giúp mình thaks
View more random threads:
Không chỉ dừng lại ở việc sử dụng nguyên liệu cao cấp, mỗi công trình còn được "chăm sóc" bằng 4 dịch vụ xuất sắc của Tre Nghệ. Từ việc tư vấn, thiết kế đến thi công và hoàn thiện, mọi quy trình đều...
Chất Lượng và Sáng Tạo: Kiến Trúc...