Here is my code in java :
try{
String query = "INSERT INTO tb_user VALUES ('"+txt_nidn.getText()+"','"+txt_nikdosen.getText()+"','"+txt_namadosen.getText()+"','"+txt_alamat.getText()+"')";
stat = koneksi.createStatement();
int res = stat.executeUpdate(query);
JOptionPane.showMessageDialog(this,"Data Berhasil Di Simpan","Informasi",JOptionPane.INFORMATION_MESSAGE);
gettabel();
bersih();
} catch (SQLException ex){
JOptionPane.showMessageDialog(null, "Proses Penyimpanan Gagal atau Cek Koneksi Anda!","Error",JOptionPane.ERROR_MESSAGE);
System.out.println(ex.getMessage());
}
Is there something wrong in my code? I can't insert some data to database, because of these erroring. Please help me :(
PreparedStatement. Once you've done that, it'll be much easier to see the details of the SQL, and the other errors will be fixed more easily. (I'd specify the columns explicitly too, personally...)tb_userdoesn't have 4 columns, check your table