The screen shown is used to enter the sales of the products into the sales and salesdetails tables. It utilizes the four depicted files ProductDAO.java, Product.java, PosDAO.java and Pos.java. The schema for the database is also depicted. The java code utilizes a jconnector to retrieve data from the database.  When a product code is entered and then a quantity is entered, on the enter key pressed, the product code is sent to the getProduct(String ID) of a ProductDAO object and that function connects to the database and retrieves the data, placing it into a Product object and return this as Product object so that it can be placed into the Jtable of the PosGUI screen.  Write the code for the getProduct(String ID) function located in the ProductDAO file. The code is equivalent to the prodid.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The screen shown is used to enter the sales of the products into the sales and salesdetails tables. It utilizes the four depicted files ProductDAO.java, Product.java, PosDAO.java and Pos.java. The schema for the database is also depicted. The java code utilizes a jconnector to retrieve data from the database. 
When a product code is entered and then a quantity is entered, on the enter key pressed, the product code is sent to the getProduct(String ID) of a ProductDAO object and that function connects to the database and retrieves the data, placing it into a Product object and return this as Product object so that it can be placed into the Jtable of the PosGUI screen.  Write the code for the getProduct(String ID) function located in the ProductDAO file. The code is equivalent to the prodid. 

Point of Sales Screen
Product Code 4225
Code
9813
3700
Product Name
Wine Muscadet Sur Lie
Compound - Rum
Save Transaction
Cancel Transaction
Quantity 20
Unit Price
34.1
32.15
I
Qty Total
15
26
X
511.5
835.9
1347.40
Transcribed Image Text:Point of Sales Screen Product Code 4225 Code 9813 3700 Product Name Wine Muscadet Sur Lie Compound - Rum Save Transaction Cancel Transaction Quantity 20 Unit Price 34.1 32.15 I Qty Total 15 26 X 511.5 835.9 1347.40
public class ProductDAO {
private Connection conn;
PreparedStatement stmt = null;
public boolean openConnection() {
try {
// db parameters
String url = "jdbc:mysql://localhost: 4306/swen 2005";
String user = "root";
}
String password = "";
// create a connection to the database
conn = DriverManager.getConnection(url, user, password);
if (conn!= null){
|}
//System.out.println("Connection Successful");
return true;
}
catch(SQLException e) {
System.out.println(e.getMessage());
try
{
| }
return false;
}
public void closeConnection()
{
}
return false;
if (conn!=null)
conn.close();
}
catch (SQLException ex) {
System.out.println(ex.getMessage());
swen2005 sales
SalesNumber: int(10)
SalesDate : date
# Sales Total: decimal(7,2)
◆ swen2005 salesdetails
number: int(10)
# SalesNumber: int(10)
prodid: varchar(20)
# price: decimal(7,2)
#qty: int(10)
.
public class PosDAO {
private Connection conn;
PreparedStatement stmt = null;
public boolean openConnection(){
try {
}
// db parameters
String url = "jdbc: mysql://localhost: 4306/swen 2005";
String user="root";
String password = "";
// create a connection to the database
conn - DriverManager.getConnection(url, user, password);
if (conn!= null){
return true;
3
}
}
catch(SQLException e) {
System.out.println(e.getMessage());
}
return false;
}
public void closeConnection ()
{
try
{
return false;
}
}
if (conn!=null)
conn.close();
catch(SQLException ex) {
System.out.println(ex.getMessage());
}
public void saveTransaction (List <Salesdetails> items) throws SQLException{
}
public List<Pos> getSales (String fromDate, String toDate) {
v swen2005 products
number: int(11)
prodid: varchar(20)
prodname : varchar(30)
#price: decimal(10,2)
#onhand : int(11)
public class Pos {
class Product{
this.salesDate = sd;
this.salesNumber - sn;
this.prodcode = pcode;
this.qty = q;
this.prodname = pname;
this.unit = ucost;
this.salesTotal = st;
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;
public String salesDate;
public int salesNumber;
public String prodcode;
public String prodname;
public double salesTotal;
public double unit;
public int qty;
public Pos(String sd,int sn, String pcode, String pname,double ucost, int q, double st)
{
prodName=name;
prodPrice=price;
prodOnHand-qty;
Transcribed Image Text:public class ProductDAO { private Connection conn; PreparedStatement stmt = null; public boolean openConnection() { try { // db parameters String url = "jdbc:mysql://localhost: 4306/swen 2005"; String user = "root"; } String password = ""; // create a connection to the database conn = DriverManager.getConnection(url, user, password); if (conn!= null){ |} //System.out.println("Connection Successful"); return true; } catch(SQLException e) { System.out.println(e.getMessage()); try { | } return false; } public void closeConnection() { } return false; if (conn!=null) conn.close(); } catch (SQLException ex) { System.out.println(ex.getMessage()); swen2005 sales SalesNumber: int(10) SalesDate : date # Sales Total: decimal(7,2) ◆ swen2005 salesdetails number: int(10) # SalesNumber: int(10) prodid: varchar(20) # price: decimal(7,2) #qty: int(10) . public class PosDAO { private Connection conn; PreparedStatement stmt = null; public boolean openConnection(){ try { } // db parameters String url = "jdbc: mysql://localhost: 4306/swen 2005"; String user="root"; String password = ""; // create a connection to the database conn - DriverManager.getConnection(url, user, password); if (conn!= null){ return true; 3 } } catch(SQLException e) { System.out.println(e.getMessage()); } return false; } public void closeConnection () { try { return false; } } if (conn!=null) conn.close(); catch(SQLException ex) { System.out.println(ex.getMessage()); } public void saveTransaction (List <Salesdetails> items) throws SQLException{ } public List<Pos> getSales (String fromDate, String toDate) { v swen2005 products number: int(11) prodid: varchar(20) prodname : varchar(30) #price: decimal(10,2) #onhand : int(11) public class Pos { class Product{ this.salesDate = sd; this.salesNumber - sn; this.prodcode = pcode; this.qty = q; this.prodname = pname; this.unit = ucost; this.salesTotal = st; 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; public String salesDate; public int salesNumber; public String prodcode; public String prodname; public double salesTotal; public double unit; public int qty; public Pos(String sd,int sn, String pcode, String pname,double ucost, int q, double st) { prodName=name; prodPrice=price; prodOnHand-qty;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Database Architectures
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education