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: no account in my database[java interface login]

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default no account in my database[java interface login]

    Good evening, folks,
    I'm a beginner in java and I'm creating an interface
    connection with the netbeans ide software.
    I would also like to link it with a local database with wampserver
    The problem is that when I write the code, everything is nicquel but
    When I create the account, I get the message register successfully
    but in the database nothing appears, please, I have the impression
    for screwing up somewhere. my code:

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            try{
                String query= "INSERT INTO `user`(`name`, `surname`, `email`, `plan`, `password`, `phone`) VALUES (?, ?, ?, ?, ?, ?)";
                con = DriverManager.getConnection("jdbc:mysql://localhost/userregistration", "root", "");
                pst = con.prepareStatement(query);
                pst.setString(1, txtName.getText());
                pst.setString(2, txtSurname.getText());
                pst.setString(3, txtEmail.getText());
                pst.setString(4, cmbPlan.getSelectedItem().toString());
                pst.setString(5, txtPass.getText());
                pst.setString(6, txtPhone.getText());
                pst.executeUpdate();
                JOptionPane.showMessageDialog(null, "REGISTER SUCCESSFULLY");
     
            }catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "REGISTER SUCCESSFULLY");
            }
        }

    And also without having put the information in the fields
    when I click on "register" I also get the message "register sucessfully"
    Thank you for helping me
    I have attached the images to my post and the code is highlighted in yellow.
    620 280 2.png
    620 280.png
    Last edited by diabirus; October 13th, 2019 at 11:43 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: no account in my database[java interface login]

    The two messages appear to have the same text.
    Also add a call to printStackTrace to the catch block to get the full text of any error message.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    diabirus (October 13th, 2019)

  4. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: no account in my database[java interface login]

    Thank you
    I don't understand well when you ask me to use the printStack trace?

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: no account in my database[java interface login]

    printStackTrace is a method in the Throwable class (parent of Exception) that will print out the contents of the error message and the call stack for where the execution flow was.
    It should always be called in a catch block to show what and where about the exception.
           }catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(null, "REGISTER NOT SUCCESSFUL");
            }
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    Oct 2019
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: no account in my database[java interface login]

    I just added, but the problem hasn't changed. Now I have the message
    "register not successfully". It's like my code is running in a loop.

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: no account in my database[java interface login]

    Can you copy the full text of the error message and paste it here? It will have info about the problem.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. NLIDB - Natural Language Interface to Database.
    By pnkjjawale in forum Java Theory & Questions
    Replies: 4
    Last Post: January 28th, 2014, 04:43 PM
  2. Replies: 1
    Last Post: December 21st, 2012, 10:35 AM
  3. login; txt file database
    By entoke in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 9th, 2012, 06:31 AM
  4. how to login to my gmail account from my jsp coding
    By mahalakshmikamaraj in forum Web Frameworks
    Replies: 1
    Last Post: January 27th, 2012, 10:15 AM