Provide the date and time when the data SQL input

Viewed 33

I have difficulty giving time for each inputting new data that will be stored in the SQL database, please provide instructions so that every time I perform an action on the input button it will be accompanied by the hour and time as well.

private void btMasukkanActionPerformed(java.awt.event.ActionEvent evt) {
    try{
        String sql =  "INSERT INTO nasabah Values ('"+
            txtCIF.getText()+"','"+
            txtNIK.getText()+"','"+
            txtNama.getText()+"','"+
            txtAlamat.getText()+"','"+
            txtTelp.getText()+"','"+
            cbCabang.getSelectedItem()+"')";
        java.sql.Connection conn = (Connection)konfig.configDB();
        java.sql.PreparedStatement pstm = conn.prepareStatement(sql);
        pstm.execute();
        JOptionPane.showMessageDialog(null, "Data berhasil di tambahkan");
        kosongkan_form();
    }catch (HeadlessException | SQLException e){
        JOptionPane.showMessageDialog(this, e.getMessage());
    } 
}
0 Answers
Related