Results 1 to 6 of 6
  1. #1
    dilshod is offline Member
    Join Date
    Jan 2012
    Posts
    11
    Rep Power
    0

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

    Help, please! Following errors are written To mine to the program.

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.mysql.jdbc.UpdatableResultSet.syncUpdate(Updat ableResultSet.java:1548)
    at com.mysql.jdbc.UpdatableResultSet.updateString(Upd atableResultSet.java:2493)
    at newpackage.forma_registratsiya.jButton1ActionPerfo rmed(forma_registratsiya.java:133)
    at newpackage.forma_registratsiya.access$000(forma_re gistratsiya.java:22)
    at newpackage.forma_registratsiya$1.actionPerformed(f orma_registratsiya.java:55)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6267)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:603 2)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)

    Program code:

    Java Code:
    try { 
    	           Class.forName("com.mysql.jdbc.Driver"); 
    	           conn = DriverManager.getConnection("jdbc:mysql://localhost/baza_zapis","root",""); 
    	           Statement sely = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 
    	           resultup = sely.executeQuery("select * from tablitsa_zapis"); 
    	             
    	         resultup.updateString(2, jTextField1.getText()); 
    	         resultup.updateString(3,jTextField2.getText()); 
    	         resultup.updateString(4, jTextField4.getText()); 
    	         resultup.updateString(5, jTextField3.getText()); 
    	         resultup.insertRow(); 
    	      
    	             } catch (SQLException ex) { 
    	           Logger.getLogger(forma_registratsiya.class.getName()).log(Level.SEVERE, null, ex); 
    	       } catch (ClassNotFoundException ex) { 
    	           try { 
    	               Logger.getLogger(forma_registratsiya.class.getName()).log(Level.SEVERE, null, ex); 
    	               resultup.insertRow(); 
    	         
    	         
    	         
    	   }                                         
    	           catch (SQLException ex1) { 
    	               Logger.getLogger(forma_registratsiya.class.getName()).log(Level.SEVERE, null, ex1); 
    	           }  }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

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

    Based on this message:

    Java Code:
    at newpackage.forma_registratsiya.jButton1ActionPerformed(forma_registratsiya.java:133)
    which line of code is line 133 of forma_registratsiya.java?

  3. #3
    dilshod is offline Member
    Join Date
    Jan 2012
    Posts
    11
    Rep Power
    0

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

    this:
    Java Code:
    resultup.updateString(4, jTextField4.getText());

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

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

    Well that tells you that either resultup or jTextField4 is null. Now your job is to first figure out which -- some println statements above the offending line of code shown above can help you with this, and then to look back into your code and figure out why it's null.

  5. #5
    dilshod is offline Member
    Join Date
    Jan 2012
    Posts
    11
    Rep Power
    0

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

    I have checked up result up and jTextField. Resultup yields result and from jTextField1 to jTextField4 I entered the text. After a line
    Java Code:
     resultup.updateString (2, jTextField1.getText ());
    The same error gives out. Help, please, will solve these errors?

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

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

    Shouldn't the resultSet actually be pointing at a row to do the updates?
    Because you haven't called next() yet...

    Also, why are you doing a set of updates on an essentially random row?

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2010, 03:19 PM
  2. Replies: 3
    Last Post: 04-30-2010, 07:44 PM
  3. Replies: 4
    Last Post: 04-01-2010, 10:34 PM
  4. Replies: 5
    Last Post: 08-26-2009, 11:37 AM
  5. Replies: 12
    Last Post: 10-05-2008, 06:52 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
  •