Create a Java FX GUI program that allows the user to insert

Create a Java FX GUI program that allows the user to insert data into a SQL database. The goal of this project is to write a basic Java FX GUI database program. The program should have a list component which on launching the program shows the contents of the database. Also the program should present the user with a form of TextFields for capturing data to insert into a database (use the CPU database you created in previous projects). The form should also have a submit button which will attempt to create a new record in the database. The data should be validated first (numbers, text, blank, etc.). If the data is invalid nothing should be inserted into the database and a warning message should be presented to the user via a Label component. If a record is inserted into the database the List should be updated to include the new record. The report needs to be in the following format: Intel Core i7-6700HQ @ 2.60GHz: $1,509.00 Intel Core i7-3770K @ 3.50GHz: $560.50 Intel Core i5-3570K @ 3.40GHz: $477.23 Intel Core i7-4700MQ @ 2.40GHz: $467.40

SQL database:

create database intelprocessors;
use intelprocessors;
show tables;

create table computers(id int not null auto_increment primary key, cpuname varchar( 32 ) not null, performance varchar( 32 ) not null, price float);

describe computers;

Solution

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.Statement;

import java.SQLException;

public class SelectStatementSample

{

   public static void main(String[ ] args) throws Exception

   {

   Connection connection = null;

   try

   {

   Class.forName(\"com.mysql.jdbc,Driver\");

   String url =\"jdbc:mysql://localhost/testdb\";

   String user = \"root\";

String password =\" \";

   connection = DriverManager.getConnection(url, user, password);

   Statement stmt = connection.createStatement();

   String sql = \"INSERT INTO users (id, cpuname, performance, price) \" + \" VALUES ( 1, \' intel \' , \'good \' , \' 10,111 \' )\" ;

   } catch(ClassNotFoundException e)

{

   System.err.println( \"Could not load database driver!\");

}catch (SQLException e)

{

   e.printstackTrace();

   } finally

   {

   if (connection !=null)

   {

   connection.close();

   }

}

}

}

Create a Java FX GUI program that allows the user to insert data into a SQL database. The goal of this project is to write a basic Java FX GUI database program.
Create a Java FX GUI program that allows the user to insert data into a SQL database. The goal of this project is to write a basic Java FX GUI database program.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site