Results 1 to 3 of 3
  1. #1
    susan is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default AWT-EventQueue-0 java.lang.NullPointerException

    Hi, Can some one please help me, i have create a form in netbeans,my backend database choice is mysql, i am having problem inserting and dispalying data from the database.

    this is the method i call when a submit button is clicked

    Java Code:
    public void InsertData()
    {
    Connection conn = null;
    //getData();
    // PreparedStatement stmt = null;
    
    //String initials ;
    
    initials = jTextField1.getText();
    name = jTextField2.getText();
    surname = jTextField10.getText();
    race = jTextField6.getText();
    // email = jTextField6.getText();
    company = jTextField3.getText();
    //String type=(String)jList1.getSelectedItem();
    
    //physical_add = jTextArea1.getText();
    // postal_add = jTextArea2.getText();
    
    System.out.println(initials);
    System.out.println(name);
    System.out.println(surname);
    System.out.println(race);
    System.out.println(company);
    
    String insertStr ="";
    String sql;
    // String sql2;
    String Statement;
    String select;
    
    //Statement stmt = conn.createStatement();
    
    
    try{
    
    sql= "insert into bus (initals, name, surname, comapany_name) values("+quotate(initials)+","+quotate(name)+","+quotate(surname)+","+quotate(company)+")";
    
    int done=stmt.executeUpdate(sql);
    
    System.out.println("shows");
    stmt.close();
    conn.close();
    
    //stmt.executeUpdate ( "INSERT INTO client( initials ) VALUES ( "+quotate(initials)+" ) " );
    
    
    
    
    jTextField8.setText("1 row inserted");
    
    getContentPane().removeAll();
    initComponents();
    
    }
    
    catch(Exception e){
    jTextField8.setText("Error occurred in inserting data");
    e.printStackTrace(System.err);
    }
    
    //String type =(String)jList1.getSelectedItem();
    }
    i get the fulling

    • java.lang.NullPointerException


    then i have my second method

    which dispalys data

    Java Code:
    private ResultSet getResultFromClient() {
    
    ResultSet rs=null;
    
    try{
    rs=stmt.executeQuery("Select * from client");
    System.out.println("name "+ rs.getString(1));
    
    }
    catch(SQLException e){}
    
    return rs;
    
    }
    i get the following

    • Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException


    Thanks

  2. #2
    Join Date
    Jul 2007
    Posts
    1
    Rep Power
    0

    Default

    Hi Susan
    What is the java, netbeans versions you are using?

  3. #3
    lakshika is offline Member
    Join Date
    Jul 2007
    Posts
    1
    Rep Power
    0

    Default

    I think the version of Netbeans does not matter as long as you are using the right platform. I'm getting the same error when compiling an earlier code that works well in java 1.5 but gives
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    in jdk1.6 .
    does any one have a solution for this?

Similar Threads

  1. java.lang.NullPointerException
    By stevemcc in forum AWT / Swing
    Replies: 2
    Last Post: 02-08-2008, 10:01 AM
  2. Replies: 3
    Last Post: 01-29-2008, 02:37 AM
  3. java.lang.NullPointerException
    By ravian in forum New To Java
    Replies: 1
    Last Post: 01-13-2008, 08:39 PM
  4. java.lang.NullPointerException
    By Felissa in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 07:02 AM
  5. Replies: 2
    Last Post: 07-02-2007, 03:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •