Site icon DataFlair

Advanced Java Project – Product Management System Part – 2

Program 1

package model;


public class Product 
{
    private int prodid;
    private String prodname;
    private int prodqty;
    private int prodamt;
    private String prodtype;

    public int getProdid() {
        return prodid;
    }

    public void setProdid(int prodid) {
        this.prodid = prodid;
    }

    public String getProdname() {
        return prodname;
    }

    public void setProdname(String prodname) {
        this.prodname = prodname;
    }

    public int getProdqty() {
        return prodqty;
    }

    public void setProdqty(int prodqty) {
        this.prodqty = prodqty;
    }

    public int getProdamt() {
        return prodamt;
    }

    public void setProdamt(int prodamt) {
        this.prodamt = prodamt;
    }

    public String getProdtype() {
        return prodtype;
    }

    public void setProdtype(String prodtype) {
        this.prodtype = prodtype;
    }
    
}

Program 2

package connection;
import java.sql.*;

public class MyConnection 
{
    static
    {
        try
        {      
           Class.forName("com.mysql.jdbc.Driver");
        } 
        catch(Exception e)
        {
          System.out.println(e);
        }    
    }
    
    public static Connection getConnection()
    {
          Connection con=null;
        try
        {   
          con=DriverManager.getConnection("jdbc:mysql://localhost/productdataflair","root","root@data");
        }
        catch(Exception e)
        {
            System.out.println(e);
        }    
        return con;  
    }
}

 

Exit mobile version