Using the getFirst() function as a template for reference, code the saveProduct() function that will be called when the save button of the depicted screen is clicked. The text from the JTextFields will be used as parameters.The database schema for the SQL tables are also depicted. The number of the product is the primary key and is set to auto-increment. public Product getFirst() { if (openConnection()) { try{ Product temp = null; String query = "SELECT * FROM products order by number asc limit 1"; // our SQL SELECT query. Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); // create the java statement ResultSet rs = st.executeQuery(query);// execute the query, and get a java resultset while (rs.next()) // iterate through the java resultset { temp = new Product(rs.getInt("number"),rs.getString("prodid"),rs.getString("prodname"),rs.getFloat("price"),rs.getInt("onhand")); } st.close(); closeConnection();
Using the getFirst() function as a template for reference, code the saveProduct() function that will be called when the save button of the depicted screen is clicked. The text from the JTextFields will be used as parameters.The database schema for the SQL tables are also depicted. The number of the product is the primary key and is set to auto-increment. public Product getFirst() { if (openConnection()) { try{ Product temp = null; String query = "SELECT * FROM products order by number asc limit 1"; // our SQL SELECT query. Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); // create the java statement ResultSet rs = st.executeQuery(query);// execute the query, and get a java resultset while (rs.next()) // iterate through the java resultset { temp = new Product(rs.getInt("number"),rs.getString("prodid"),rs.getString("prodname"),rs.getFloat("price"),rs.getInt("onhand")); } st.close(); closeConnection();
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Using the getFirst() function as a template for reference, code the saveProduct() function that will be called when the save button of the depicted screen is clicked. The text from the JTextFields will be used as parameters.The
public Product getFirst()
{
if (openConnection())
{
try{
Product temp = null;
String query = "SELECT * FROM products order by number asc limit 1"; // our SQL SELECT query.
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); // create the java statement
ResultSet rs = st.executeQuery(query);// execute the query, and get a java resultset
while (rs.next()) // iterate through the java resultset
{
temp = new Product(rs.getInt("number"),rs.getString("prodid"),rs.getString("prodname"),rs.getFloat("price"),rs.getInt("onhand"));
}
st.close();
closeConnection();
return temp;
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
closeConnection();
return null;
}
class Product{
public int number;
public String prodID;
public String prodName;
public float prodPrice;
public int prodOnHand;
Product(int num,String id, String name, float price, int qty)
{
number=num;
prodID=id;
prodName=name;
prodPrice=price;
prodOnHand=qty;
}
}

Transcribed Image Text:swen2005 sales
SalesNumber: int(10)
SalesDate : date
# Sales Total : decimal(7,2)
V swen2005 salesdetails
number: int(10)
# SalesNumber : int(10)
Ⓒ prodid: varchar(20)
# price : decimal(7,2)
# qty: int(10)
swen2005 products
number : int(11)
prodid: varchar(20)
Ⓒ prodname : varchar(30)
# price : decimal(10,2)
#onhand int(11)

Transcribed Image Text:Product Data Entry Screen
Product ID
Product Name
Product Price
OnHand
Save
Delete
Cancel
First
Next
Previous
Last
1
Close
X
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY