swing - Registration form Null pointer Exception in Java Netbeans 7.01 -


i have created registration form own project. runs when execute code. when fill out form , click login button, prompt message java.lang.nullpointerexception. how can solve problem?

this code:

import javax.swing.*; import java.sql.*;   public class signup extends javax.swing.jframe {      connection conn = null;     preparedstatement ps = null;     resultset rs = null;       /** creates new form signup */     public signup() {         initcomponents();          conn = connection.connectdb();      } private void jbutton1actionperformed(java.awt.event.actionevent evt) {      if (evt.getsource() == jbutton1)          {             int x = 0;             string s1 = jtextfield1.gettext();             string s2 = jtextfield2.gettext();              char[] s3 = jpasswordfield1.getpassword();             char[] s4 = jpasswordfield2.getpassword();              string s8 = new string(s3);             string s9 = new string(s4);              string s5 = jtextfield5.gettext();             string s6 = jtextfield6.gettext();             string s7 = jtextfield7.gettext();              if(s8.equals(s9))             {                 try                 {                 preparedstatement ps = conn.preparestatement("insert registration values(?,?,?,?,?,?)");                     ps.setstring(1, s1);                     ps.setstring(2, s2);                     ps.setstring(3, s8);                     ps.setstring(4, s5);                     ps.setstring(5, s6);                     ps.setstring(6, s7);                     resultset rs = ps.executequery();                     x++;                     if (x > 0)                      {                         joptionpane.showmessagedialog(jbutton1, "data saved successfully");                     }                 }                 catch(exception e)                 {                     system.out.println(e);                 }             }             else             {                 joptionpane.showmessagedialog(jbutton1, "password dosn't match");             }      }      else     {         jtextfield1.settext("");             jtextfield2.settext("");             jpasswordfield1.settext("");             jpasswordfield2.settext("");             jtextfield5.settext("");             jtextfield6.settext("");             jtextfield7.settext("");     }  } 


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -