try catch block not work in action performed

Discussion in 'Java' started by midomorsy, Jun 14, 2017.

  1. midomorsy

    midomorsy

    Joined:
    Jun 14, 2017
    Messages:
    1
    Likes Received:
    0
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed


    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    JOptionPane.showMessageDialog(null, "Class Loaded");
    Connection conn = DriverManager.getConnection("jdbc:eek:racle:thin:mad:localhost:1521:xe", "midos", "mido");
    JOptionPane.showMessageDialog(null, "connection Succeded");
    PreparedStatement stmt=conn.prepareStatement("insert into empl(id ,name,salary) values('"+t_id+"','"+t_name+"','"+t_Sal+"')");
    int c= stmt.executeUpdate();
    if (c>0)JOptionPane.showMessageDialog(null, "Data Updated");
    conn.close();
    } catch (ClassNotFoundException e) {
    } catch (SQLException e) {
    }
    }
     
    midomorsy, Jun 14, 2017
    #1
    1. Advertisements

  2. midomorsy

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    118
    Likes Received:
    14
    Location:
    Malaysia
    What did you mean by not working ? You are not adding any code inside catch method.

    Try add some code inside catch block and see what the result is.
    Code (Java):
    catch (ClassNotFoundException e) {
           e.printStackTrace(); // add this line
    }
     
    Last edited: Jun 15, 2017
    John Joe, Jun 15, 2017
    #2
    Ian likes this.
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.