Java JDBC Tutorial – Part 12.6: Connect Java Swing GUI to a MySQL Database

In this video we will learn how to to connect a Java GUI to a MySQL database. We will create a form to add data into the database.

Please SUBSCRIBE to this channel

Download Java Source Code

Did you like my blog post?

Signup now and receive an email when I publish new luv2code content.

I agree to have my personal information transfered to AWeber ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

5 Comments

  1. Comments  Jason   |  Tuesday, 04 November 2014 at 10:49 pm

    Hey me again 😀 i have created a Jtable with text fields and etc. everything works fine but instead of salary im trying to create a Date of Birth field… everything looks fine except these lines.

    protected void saveEmployee() {

    // get the employee info from gui
    String firstName = firstNameTextField.getText();
    String lastName = lastNameTextField.getText();
    String jobTitle = jobTitleTextField.getText();
    Date dateOfBirth = dateOfBirthDateField.getDate();
    Date dateOfBirthDate = dateOfBirthDate.getText();
    //Date dateOfBirth = convertDateToString(dateOfBirthStr);

    Employee tempEmployee = new Employee(lastName,
    firstName, jobTitle, dateOfBirth);

    Any chance you could help me out on how to add dates?

  2. Comments  Jason   |  Tuesday, 04 November 2014 at 10:52 pm

    by the way getting date from database works fine, but adding date from GUI to the table is where my struggle starts

  3. Comments  Chad Darby   |  Wednesday, 05 November 2014 at 12:48 pm

    Hi Jason,

    I just made a new blog post for adding a Date of Birth field (source code included). Enjoy!

    http://goo.gl/nfQJrq

  4. Comments  James   |  Tuesday, 28 February 2017 at 6:39 am

    Hello, I’m James and I’m desperate need of your help.

    I followed every tutorial up until 12.6, adding of a user. I am at a dead end here cause my AddEmployeeDialog will not run. It’s showing an error at
    Employee tempEmployee = new Employee(firstName, lastName, email, salary);

    Is it not something to do with the “id” variable which is not declared in this situation?

    James
    Regards

  5. Comments  Chad Darby   |  Tuesday, 28 February 2017 at 9:12 am

    Hi James,

    Here’s a link to the solution code from the video. You can compare your code against the solution.

    http://www.luv2code.com/wp-content/uploads/2014/09/jdbc-swing-gui-add-employee.zip

    If you are not able to find the problem, then you can use the solution code as a starting point and continue from there.

    Let me know if you need anything else.

    :-)

Leave a Reply