Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Having issues with simple logIn --- insert new user to th db

  1. #1
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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.

    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){
     
    				}
     
    			}	
    		});
     
    	}


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default 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?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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.

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default 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:
    ex.printStackTrace();
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  5. #5
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Having issues with simple logIn --- insert new user to th db

    hey, I was out. Here is th error :

    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)

  6. #6
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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

Similar Threads

  1. Insert != null check issues
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 4th, 2012, 12:30 PM
  2. login to website as user, no browser
    By chopficaro in forum Java Theory & Questions
    Replies: 6
    Last Post: May 27th, 2010, 06:55 PM
  3. Best way to automatically login user from a customer's web site.
    By ess_stegra in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: February 2nd, 2010, 12:16 PM
  4. simple login web service
    By mr_aliagha in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: January 5th, 2010, 03:49 PM
  5. Replies: 1
    Last Post: July 28th, 2009, 02:15 AM