Having issues with simple logIn --- insert new user to th db
Hello,
I have a slight problem with a simple swing program.
I created a simple program for user to logIn this part is working. But when I want to register new user into db it doesn't work.
Can you pls look at my code nd help me. I tried to search, but it's just getting confusing. Thank you very much.
Code :
butReg.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String username =JOptionPane.showInputDialog(null, "Enter new username" );
String pass = JOptionPane.showInputDialog(null, "Enter new password" );
try{
String insert = ("INSERT INTO login (account) " + "(Username, password)" + "VALUES ('" + username + "', '" + pass + "' )");
stat2 = (Statement) con.createStatement();
stat2.executeUpdate(insert /*"INSERT INTO users" + "(Username, Password ) VALUES" + " (?,?)"*/);
}
catch(Exception ex){
}
}
});
}
Re: Having issues with simple logIn --- insert new user to th db
What do you mean by: "it doesn't work"? Are you getting errors or something?
Re: Having issues with simple logIn --- insert new user to th db
No errors at all,
but when i look into my db the new values aren't there. :/ it's not updating my db.
Re: Having issues with simple logIn --- insert new user to th db
Well, since you are catching errors but not printing them, you would not know if there are errors. Put this line in your catch(Exception ex){ } block and tell me if you get any errors:
Re: Having issues with simple logIn --- insert new user to th db
hey, I was out. Here is th error :
Quote:
java.lang.NullPointerException
at LogInMysql$2.actionPerformed(LogInMysql.java:127)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Re: Having issues with simple logIn --- insert new user to th db
Thank you for your help :) I fixed this and now I can put all th small parts into the main program :) Thank you