Results 1 to 2 of 2
  1. #1
    cyborg911 is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

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

    I am getting the following error on execution of the program,the highlighted line is Line number 113 from the errorcode:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at login.Purchase.actionPerformed(Purchase.java:113)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.jav a:6504)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
    at java.awt.Component.processEvent(Component.java:626 9)
    at java.awt.Container.processEvent(Container.java:222 9)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4860)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
    at java.awt.Component.dispatchEvent(Component.java:46 86)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2713 )
    at java.awt.Component.dispatchEvent(Component.java:46 86)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101 )
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 677)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)






    Connection con;

    @Override
    public void actionPerformed(ActionEvent e) {
    try {
    String dbURL = "jdbc:mysql://localhost:3306/";
    String username = "root";
    String password = "";
    String dbName = "test";
    String driver = "com.mysql.jdbc.Driver";
    try {
    Class.forName(driver).newInstance();
    } catch (InstantiationException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    }
    try {
    con = (Connection) DriverManager.getConnection(dbURL+dbName, username, password);
    } catch (SQLException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    }
    Statement st= null;
    try {
    st = (Statement) con.createStatement();
    } catch (SQLException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    }
    try {
    st.executeUpdate("INSERT purchase VALUES('"+jtf1.getText()+"','"+jtf2.getText()+"',' "+jtf3.getText()+"','"+jtf4.getText()+"','"+jtf5.g etText()+"')");
    } catch (SQLException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    }

    } catch (ClassNotFoundException ex) {
    Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex);
    }

    }

    }

  2. #2
    doWhile is online now Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default Re: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    What is null on line 113? Are there any SERVER logging statements? We don't have the full class, thus don't know what line 113 is, and can only guess what could be null. Add some debugging statements in there to see what could not have been instantiated

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2010, 03:19 PM
  2. Replies: 0
    Last Post: 05-28-2010, 02:47 PM
  3. Replies: 3
    Last Post: 04-30-2010, 07:44 PM
  4. Replies: 5
    Last Post: 08-26-2009, 11:37 AM
  5. Replies: 6
    Last Post: 08-03-2009, 08:58 PM

Posting Permissions

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