Skip to main content

[ASK]Bugs of Java or Wrong Code?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
vikar
Offline
Joined: 2013-07-27

Dear All,
What this is bugs of Java or me not to understand java programming, this my piece code :
String kode = txtKode.getText();
String nama = inputNama.getText();
String keterangan = inputKeterangan.getText();

try {
Connection c = KoneksiMySql.getKoneksi();
String sql = "UPDATE UNIT SET NAMA=?, KETERANGAN=?, WKT_INPUT=now() WHERE KODE=?";
PreparedStatement p = c.prepareStatement(sql);

p.setString(1, nama);
p.setString(2, keterangan);
p.setString(3, kode);

p.executeUpdate();
p.close();
JOptionPane.showMessageDialog(null, "Data Berubah",
"Pemberitahuan", JOptionPane.INFORMATION_MESSAGE);
} catch(SQLException e) {
System.out.println("Error : " + e);
JOptionPane.showMessageDialog(null, "Proses Rubah Unit Gagal",
"Pesan Error", JOptionPane.ERROR_MESSAGE);
}finally {
inputNama.setText(null);
inputKeterangan.setText(null);
btnTambah.setEnable(true);
btnHapus.setEnabled(false);
btnRubah.setEnabled(false);
inputNama.requestFocus();
}

JOptionPane is Show and no error appears but data in database does not change, and code in block finally not executed.
i'm use jInternalFrame, first run Only 'Add Button, Search Button' enable and other button are disable, then when 'Search Button' is clicked and open other jInternalFrame and get data form database, 'Add button' Disable and 'Delete Button, Change Button' are Enable. that my piece code on Change Button ActionPerformed.

Please it's support.
Thanks,
Best & Regrads.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vikar
Offline
Joined: 2013-07-27

Thanks for the support, i have solve my problem. The problem it's located in Instance of jInternalFrame.
I Love Java ^_^.