When the Search button is pressed in the screen depicted, the getSales() function from the PosDAO.java class is called, the parameters of this function are the from date and to date. The getSales () function should return a list of Pos objects that matches the criteria specified, Note this function has to perform two INNER JOINs in to combine all three tables in order to get all the needed data to fill the Pos object. The database schema is also depicted. The PosDAO, Product, SalesDetails and Pos classes are shown BELOW Write the getSales() function
When the Search button is pressed in the screen depicted, the getSales() function from the PosDAO.java class is called, the parameters of this function are the from date and to date. The getSales () function should return a list of Pos objects that matches the criteria specified, Note this function has to perform two INNER JOINs in to combine all three tables in order to get all the needed data to fill the Pos object. The database schema is also depicted. The PosDAO, Product, SalesDetails and Pos classes are shown BELOW Write the getSales() function
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
100%
When the Search button is pressed in the screen depicted, the getSales() function from the PosDAO.java class is called, the parameters of this function are the from date and to date.
The getSales () function should return a list of Pos objects that matches the criteria specified, Note this function has to perform two INNER JOINs in to combine all three tables in order to get all the needed data to fill the Pos object. The
Write the getSales() function
public class PosDAO {
private Connection conn;
PreparedStatement stmt = null;
public boolean openConnection(){
try {
// db parameters
String url = "jdbc:mysql://localhost:4306/swen2005";
String user = "root";
String password = "";
// create a connection to the database
conn = DriverManager.getConnection(url, user, password);
if (conn!= null){
return true;
}
}
catch(SQLException e){
System.out.println(e.getMessage());
return false;
}
return false;
}
public void closeConnection()
{
try
{
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){
}
}
public class Pos {
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)
{
this.salesDate = sd;
this.salesNumber = sn;
this.prodcode = pcode;
this.qty = q;
this.prodname = pname;
this.unit = ucost;
this.salesTotal = st;
}
}
class Salesdetails {
public String prodcode;
public String prodname;
public double unit;
public int qty;
public Salesdetails(String pcode,String pname,double ucost, int q)
{
this.prodcode = pcode;
this.qty = q;
this.prodname = pname;
this.unit = ucost;
}
}
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;
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 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