SlideShare a Scribd company logo
2
Most read
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();
}
}
}
}

More Related Content

PDF
InterConnect2016: WebApp Architectures with Java and Node.js
PPTX
Spring batch for large enterprises operations
PPT
Java Programming for Designers
PPT
Sql injection
PDF
I am looking for some assistance with SQLite database. I have tried se.pdf
PPS
Jdbc example program with access and MySql
PDF
IPaste SDK v.1.0
PPTX
Image Converter
InterConnect2016: WebApp Architectures with Java and Node.js
Spring batch for large enterprises operations
Java Programming for Designers
Sql injection
I am looking for some assistance with SQLite database. I have tried se.pdf
Jdbc example program with access and MySql
IPaste SDK v.1.0
Image Converter

Similar to Create a Java FX GUI program that allows the user to insert data int.pdf (20)

PDF
Flask jwt authentication tutorial
PDF
9 Python programming notes for ktu physics and computer application semester 4
DOCX
Lab 2 Work with Dictionary and Create Relational Database (60 pts.).docx
PDF
Ice mini guide
PPT
EJB 3.0 Java Persistence with Oracle TopLink
PPTX
Struts 2 – Database Access
DOC
CS2309 JAVA LAB MANUAL
DOCX
Accessing data with android cursors
DOCX
Accessing data with android cursors
DOCX
Lab 2 Work with Dictionary and Create Relational Database (60 pts.docx
PDF
Triggers and Stored Procedures
ODP
Handling Database Deployments
DOCX
How to use sq lite with java using net beans
PPT
PPTX
Sql Injection and Entity Frameworks
PPTX
Database in Android
PPT
Hackers Paradise SQL Injection Attacks
PPSX
Pro Techniques for the SSAS MD Developer
PDF
Data Secrets From a Platform Engineer (Bilbro)
PPTX
An introduction to Flask and Sqlite3 - revision 1
Flask jwt authentication tutorial
9 Python programming notes for ktu physics and computer application semester 4
Lab 2 Work with Dictionary and Create Relational Database (60 pts.).docx
Ice mini guide
EJB 3.0 Java Persistence with Oracle TopLink
Struts 2 – Database Access
CS2309 JAVA LAB MANUAL
Accessing data with android cursors
Accessing data with android cursors
Lab 2 Work with Dictionary and Create Relational Database (60 pts.docx
Triggers and Stored Procedures
Handling Database Deployments
How to use sq lite with java using net beans
Sql Injection and Entity Frameworks
Database in Android
Hackers Paradise SQL Injection Attacks
Pro Techniques for the SSAS MD Developer
Data Secrets From a Platform Engineer (Bilbro)
An introduction to Flask and Sqlite3 - revision 1
Ad

More from arhamnighty (20)

PDF
Besides using the certificates, suggest alternate method to avoid th.pdf
PDF
X mun( oomiB9@@e SolutionAnswerThe image represents the.pdf
PDF
Which of these is not a way for a cell to obtain nutrients and other.pdf
PDF
Which of the following receptors is most likely to exhibit tonic adap.pdf
PDF
Which of the following is not a contribution of Robert Koch and his .pdf
PDF
When RNA from a specific strain of TMV is mixed with coat protein fro.pdf
PDF
What are the sources of Ductility for structures What is more du.pdf
PDF
What are some examples of self love in Pride and PrejudiceSolut.pdf
PDF
Using the phylogenetic tree shown, state the basal taxon Using the p.pdf
PDF
Use attached Table A-2 for Normal Distribution to find the critical .pdf
PDF
Based on the data provided through the U.S. Department of the Treasu.pdf
PDF
Trace the major historical developments of hospitals in the United S.pdf
PDF
The role of Ca2+ in the control of muscle contraction is to1. caus.pdf
PDF
The following data. recorded in days, represent the length of time to.pdf
PDF
Suppose that A and B are in DSPACE(n). Prove that the following lang.pdf
PDF
Some new protocols such as Internet Protocol (IP) version 6 are not .pdf
PDF
Selection of favorite fruits and responses of orange, grape, apple, .pdf
PDF
RNA and DNA differRNA and DNA differE-All of these are correct..pdf
PDF
Propose a pathway(s) to explain how the ectoderm and the notochord b.pdf
PDF
Potassium has one electron in its outer shell. Which of the followin.pdf
Besides using the certificates, suggest alternate method to avoid th.pdf
X mun( oomiB9@@e SolutionAnswerThe image represents the.pdf
Which of these is not a way for a cell to obtain nutrients and other.pdf
Which of the following receptors is most likely to exhibit tonic adap.pdf
Which of the following is not a contribution of Robert Koch and his .pdf
When RNA from a specific strain of TMV is mixed with coat protein fro.pdf
What are the sources of Ductility for structures What is more du.pdf
What are some examples of self love in Pride and PrejudiceSolut.pdf
Using the phylogenetic tree shown, state the basal taxon Using the p.pdf
Use attached Table A-2 for Normal Distribution to find the critical .pdf
Based on the data provided through the U.S. Department of the Treasu.pdf
Trace the major historical developments of hospitals in the United S.pdf
The role of Ca2+ in the control of muscle contraction is to1. caus.pdf
The following data. recorded in days, represent the length of time to.pdf
Suppose that A and B are in DSPACE(n). Prove that the following lang.pdf
Some new protocols such as Internet Protocol (IP) version 6 are not .pdf
Selection of favorite fruits and responses of orange, grape, apple, .pdf
RNA and DNA differRNA and DNA differE-All of these are correct..pdf
Propose a pathway(s) to explain how the ectoderm and the notochord b.pdf
Potassium has one electron in its outer shell. Which of the followin.pdf
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Lesson notes of climatology university.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Institutional Correction lecture only . . .
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
master seminar digital applications in india
Microbial disease of the cardiovascular and lymphatic systems
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Complications of Minimal Access Surgery at WLH
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Supply Chain Operations Speaking Notes -ICLT Program
human mycosis Human fungal infections are called human mycosis..pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Lesson notes of climatology university.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
A systematic review of self-coping strategies used by university students to ...
2.FourierTransform-ShortQuestionswithAnswers.pdf
Institutional Correction lecture only . . .
VCE English Exam - Section C Student Revision Booklet
master seminar digital applications in india

Create a Java FX GUI program that allows the user to insert data int.pdf

  • 1. 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";
  • 2. 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(); } } } }