WebDev Hell
This commit is contained in:
		
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -60,3 +60,10 @@
 | 
				
			|||||||
/Semester 2/Assignments/MP5-Binary-Files_CalebFontenot/build/
 | 
					/Semester 2/Assignments/MP5-Binary-Files_CalebFontenot/build/
 | 
				
			||||||
/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/target/
 | 
					/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/target/
 | 
				
			||||||
/Semester 2/Assignments/SuppliersPartsDatabase/target/
 | 
					/Semester 2/Assignments/SuppliersPartsDatabase/target/
 | 
				
			||||||
 | 
					/Semester 2/Exams/ProgrammingExam1_CalebFontenot/target/
 | 
				
			||||||
 | 
					/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/target/
 | 
				
			||||||
 | 
					/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/target/
 | 
				
			||||||
 | 
					/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/target/
 | 
				
			||||||
 | 
					/Semester 2/Exams/ProgrammingExam1Question5/target/
 | 
				
			||||||
 | 
					/Semester 2/Assignments/suppliers_parts_old/target/
 | 
				
			||||||
 | 
					/Semester 2/Assignments/SuppliersPartsDatabase_old/target/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.DBase;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.part.Part;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.part.DatabaseManipulationPart;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.SessionScoped;
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage;
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage.Severity;
 | 
				
			||||||
 | 
					import jakarta.faces.context.FacesContext;
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Named(value = "partsBean")
 | 
				
			||||||
 | 
					@SessionScoped
 | 
				
			||||||
 | 
					public class PartsBean implements Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    DBase dms = new DatabaseManipulationPart();
 | 
				
			||||||
 | 
					    List<Part> parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public PartsBean()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        parts = dms.listAll();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<Part> getParts()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return parts;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void saveFromUpdate()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int totalRowsUpdated = 0;
 | 
				
			||||||
 | 
					        for (Part s : this.parts)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (s.isModify())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    int rowsUpdated = this.dms.update(s);
 | 
				
			||||||
 | 
					                    if (rowsUpdated > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        totalRowsUpdated += rowsUpdated;
 | 
				
			||||||
 | 
					                        s.setModify(false);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception e)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    String msg = ("Numbers of rows updated is 0.");
 | 
				
			||||||
 | 
					                    addMessage(msg, e.getMessage(), FacesMessage.SEVERITY_ERROR);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String msg = ("Numbers of rows updated: " + totalRowsUpdated);
 | 
				
			||||||
 | 
					        addMessage(msg, "no exception", FacesMessage.SEVERITY_INFO);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void addMessage(String summary, String detail, Severity severity)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        FacesMessage msg = new FacesMessage(severity, summary, detail);
 | 
				
			||||||
 | 
					        FacesContext.getCurrentInstance().addMessage(null, msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -60,6 +60,14 @@ public class SupplierBean implements Serializable
 | 
				
			|||||||
        addMessage(msg, "no exception", FacesMessage.SEVERITY_INFO);
 | 
					        addMessage(msg, "no exception", FacesMessage.SEVERITY_INFO);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    public void deleteRow() {
 | 
				
			||||||
 | 
					        for (Supplier s: this.suppliers) {
 | 
				
			||||||
 | 
					            if (s.isDelete()) {
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void addMessage(String summary, String detail, Severity severity)
 | 
					    public void addMessage(String summary, String detail, Severity severity)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        FacesMessage msg = new FacesMessage(severity, summary, detail);
 | 
					        FacesMessage msg = new FacesMessage(severity, summary, detail);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,4 +19,6 @@ public interface DBase<T>
 | 
				
			|||||||
  int update( T t)
 | 
					  int update( T t)
 | 
				
			||||||
          throws SQLException;
 | 
					          throws SQLException;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  int delete (T t) throws SQLException;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ public class UtilitiesDatabase
 | 
				
			|||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        String ip = "localhost"; //internet connection
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
					        String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?allowPublicKeyRetrieval=true&useSSL=false";
 | 
				
			||||||
        try
 | 
					        try
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            con = DriverManager.getConnection(url, userName, password);
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,8 +24,8 @@ public class DatabaseManipulationPart implements DBase<Part>
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        List<Part> tableParts = new ArrayList<Part>();
 | 
					        List<Part> tableParts = new ArrayList<Part>();
 | 
				
			||||||
        String databaseName = "suppliers_parts_23";
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
        String userName = "root";
 | 
					        String userName = "java";
 | 
				
			||||||
        String password = "root";
 | 
					        String password = "1KUZ4r6.73IGu*18";
 | 
				
			||||||
        String URL2 = "com.mysql.jdbc.Driver";
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
        Connection con = new UtilitiesDatabase().connection(
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
                databaseName, userName, password, URL2);
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
@@ -86,6 +86,60 @@ public class DatabaseManipulationPart implements DBase<Part>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 @Override
 | 
					 @Override
 | 
				
			||||||
    public int update(Part t)
 | 
					    public int update(Part t)
 | 
				
			||||||
 | 
					            throws SQLException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "java";
 | 
				
			||||||
 | 
					        String password = "1KUZ4r6.73IGu*18";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        int result = 0;
 | 
				
			||||||
 | 
					        PreparedStatement updatePart = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					            updatePart = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "UPDATE part SET pnumber=?, pname=?, color=?, city=? where pnumber=?");
 | 
				
			||||||
 | 
					            updatePart.setString(1, t.getPnumber());
 | 
				
			||||||
 | 
					            updatePart.setString(2, t.getPname());     
 | 
				
			||||||
 | 
					            updatePart.setString(3, t.getColor());
 | 
				
			||||||
 | 
					            updatePart.setString(4, t.getColor());
 | 
				
			||||||
 | 
					            updatePart.setString(5, t.getPnumber());
 | 
				
			||||||
 | 
					            result = updatePart.executeUpdate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (SQLException ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					            throw ex;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new UtilitiesDatabase().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updatePart != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    updatePart.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					                throw sqle;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int delete(Part t) throws SQLException
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,68 +8,65 @@ package edu.slcc.asdv.bl.part;
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author asdv5
 | 
					 * @author asdv5
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class Part
 | 
					public class Part {
 | 
				
			||||||
{
 | 
					
 | 
				
			||||||
    private String pnumber;
 | 
					    private String pnumber;
 | 
				
			||||||
    private String pname;
 | 
					    private String pname;
 | 
				
			||||||
    private String color;
 | 
					    private String color;
 | 
				
			||||||
    private String city;
 | 
					    private String city;
 | 
				
			||||||
 | 
					    private boolean modify;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Part(String pnumber, String pname, String color, String city)
 | 
					    public boolean isModify() {
 | 
				
			||||||
    {
 | 
					        return modify;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setModify(boolean modify) {
 | 
				
			||||||
 | 
					        this.modify = modify;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Part(String pnumber, String pname, String color, String city) {
 | 
				
			||||||
        this.pnumber = pnumber;
 | 
					        this.pnumber = pnumber;
 | 
				
			||||||
        this.pname = pname;
 | 
					        this.pname = pname;
 | 
				
			||||||
        this.color = color;
 | 
					        this.color = color;
 | 
				
			||||||
        this.city = city;
 | 
					        this.city = city;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getColor() {
 | 
				
			||||||
    public String getColor()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return color;
 | 
					        return color;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setColor(String color)
 | 
					    public void setColor(String color) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.color = color;
 | 
					        this.color = color;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getCity()
 | 
					    public String getCity() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return city;
 | 
					        return city;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setCity(String city)
 | 
					    public void setCity(String city) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.city = city;
 | 
					        this.city = city;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getPname()
 | 
					    public String getPname() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return pname;
 | 
					        return pname;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setPname(String pname)
 | 
					    public void setPname(String pname) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.pname = pname;
 | 
					        this.pname = pname;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getPnumber()
 | 
					    public String getPnumber() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return pnumber;
 | 
					        return pnumber;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setPnumber(String pnumber)
 | 
					    public void setPnumber(String pnumber) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.pnumber = pnumber;
 | 
					        this.pnumber = pnumber;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public String toString()
 | 
					    public String toString() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return "Part{" + "pnumber=" + pnumber + ", pname=" + pname + ", color=" + color + ", city=" + city + '}';
 | 
					        return "Part{" + "pnumber=" + pnumber + ", pname=" + pname + ", color=" + color + ", city=" + city + '}';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,8 +25,8 @@ public class DatabaseManipulationSupplier implements DBase<Supplier>
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        List<Supplier> tableSuppliers = new ArrayList<Supplier>();
 | 
					        List<Supplier> tableSuppliers = new ArrayList<Supplier>();
 | 
				
			||||||
        String databaseName = "suppliers_parts_23";
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
        String userName = "root";
 | 
					        String userName = "java";
 | 
				
			||||||
        String password = "root";
 | 
					        String password = "1KUZ4r6.73IGu*18";
 | 
				
			||||||
        String URL2 = "com.mysql.jdbc.Driver";
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
        Connection con = new UtilitiesDatabase().connection(
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
                databaseName, userName, password, URL2);
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
@@ -85,8 +85,8 @@ public class DatabaseManipulationSupplier implements DBase<Supplier>
 | 
				
			|||||||
            throws SQLException
 | 
					            throws SQLException
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        String databaseName = "suppliers_parts_23";
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
        String userName = "root";
 | 
					        String userName = "java";
 | 
				
			||||||
        String password = "root";
 | 
					        String password = "1KUZ4r6.73IGu*18";
 | 
				
			||||||
        String URL2 = "com.mysql.jdbc.Driver";
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
        Connection con = new UtilitiesDatabase().connection(
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
                databaseName, userName, password, URL2);
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
@@ -137,4 +137,61 @@ public class DatabaseManipulationSupplier implements DBase<Supplier>
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void main(String[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        DatabaseManipulationSupplier dmp = new DatabaseManipulationSupplier();
 | 
				
			||||||
 | 
					        System.out.println(dmp.listAll());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int delete(Supplier t) throws SQLException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					           String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "java";
 | 
				
			||||||
 | 
					        String password = "1KUZ4r6.73IGu*18";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        int result = 0;
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    //"UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?"
 | 
				
			||||||
 | 
					                   "DELETE FROM supplier WHERE snumber=? "
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					           updateSupplier.setString(1, t.getSnumber());
 | 
				
			||||||
 | 
					            result = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (SQLException ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					            throw ex;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new UtilitiesDatabase().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					                throw sqle;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.supplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage;
 | 
				
			||||||
 | 
					import jakarta.faces.component.UIComponent;
 | 
				
			||||||
 | 
					import jakarta.faces.context.FacesContext;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.FacesValidator;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.Validator;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.ValidatorException;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@FacesValidator("dateValidator")
 | 
				
			||||||
 | 
					public class DateValidator implements Validator {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
 | 
				
			||||||
 | 
					        String dateStr = (String) value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dateStr == null || dateStr.trim().isEmpty()) {
 | 
				
			||||||
 | 
					            return; // Empty values are not validated.
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        dateFormat.setLenient(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            dateFormat.parse(dateStr);
 | 
				
			||||||
 | 
					        } catch (ParseException e) {
 | 
				
			||||||
 | 
					            throw new ValidatorException(new FacesMessage("Invalid date format. Please use yyyy-MM-dd."));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.supplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage;
 | 
				
			||||||
 | 
					import jakarta.faces.component.UIComponent;
 | 
				
			||||||
 | 
					import jakarta.faces.context.FacesContext;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.FacesValidator;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.Validator;
 | 
				
			||||||
 | 
					import jakarta.faces.validator.ValidatorException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@FacesValidator("numericValidator")
 | 
				
			||||||
 | 
					public class NumericValidator implements Validator {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
 | 
				
			||||||
 | 
					        String input = value.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (input == null || !input.matches("\\d+")) {
 | 
				
			||||||
 | 
					            throw new ValidatorException(new FacesMessage("Please enter a valid numeric value."));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -17,9 +17,19 @@ public class Supplier implements Serializable
 | 
				
			|||||||
    private String birthday;
 | 
					    private String birthday;
 | 
				
			||||||
    private int status;
 | 
					    private int status;
 | 
				
			||||||
    private String city;
 | 
					    private String city;
 | 
				
			||||||
    
 | 
					    private boolean delete;
 | 
				
			||||||
    private boolean modify;
 | 
					    private boolean modify;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isDelete()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return delete;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setDelete(boolean delete)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.delete = delete;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean isModify()
 | 
					    public boolean isModify()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return modify;
 | 
					        return modify;
 | 
				
			||||||
@@ -39,6 +49,7 @@ public class Supplier implements Serializable
 | 
				
			|||||||
        this.status = status;
 | 
					        this.status = status;
 | 
				
			||||||
        this.city = city;
 | 
					        this.city = city;
 | 
				
			||||||
        this.modify = false;
 | 
					        this.modify = false;
 | 
				
			||||||
 | 
					        this.delete = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getCity()
 | 
					    public String getCity()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html"
 | 
				
			||||||
 | 
					      xmlns:f="http://xmlns.jcp.org/jsf/core"
 | 
				
			||||||
 | 
					      xmlns:p="http://primefaces.org/ui">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <p:growl id="globalgrowl" showDetail="false" showSummary="true"  life="2000"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:dataTable  var="part"  
 | 
				
			||||||
 | 
					                          value="#{partsBean.getParts()}"  >
 | 
				
			||||||
 | 
					                <f:facet name="header"> <h:outputText value="Parts Table" style="font-size: 1.2em"/></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="pnumber" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="true" value="#{part.pnumber}"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="pname" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!part.modify}"  value="#{part.pname}">
 | 
				
			||||||
 | 
					                        <f:validateLength minimum="0" maximum="20" />
 | 
				
			||||||
 | 
					                    </h:inputText>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="color" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!part.modify}"  value="#{part.color}">
 | 
				
			||||||
 | 
					                        <f:validateLength minimum="0" maximum="20" />
 | 
				
			||||||
 | 
					                    </h:inputText>
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="city" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!part.modify}"  value="#{part.city}">
 | 
				
			||||||
 | 
					                        <f:validateLength minimum="0" maximum="20" />
 | 
				
			||||||
 | 
					                    </h:inputText>
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="update" /></f:facet>                
 | 
				
			||||||
 | 
					                    <h:selectBooleanCheckbox  onclick="submit()"
 | 
				
			||||||
 | 
					                                              value="#{part.modify}">
 | 
				
			||||||
 | 
					                    </h:selectBooleanCheckbox >
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					            </h:dataTable>
 | 
				
			||||||
 | 
					            <h:commandButton value="Save" action="#{partsBean.saveFromUpdate()}" />
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -19,29 +19,34 @@
 | 
				
			|||||||
                    <f:facet name="header"> <h:outputText value="snumber" /></f:facet>                
 | 
					                    <f:facet name="header"> <h:outputText value="snumber" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <h:inputText disabled ="true" value="#{supplier.snumber}"/>
 | 
					                    <h:inputText disabled ="true" value="#{supplier.snumber}"/>
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
                </h:column>
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <h:column> 
 | 
					                <h:column> 
 | 
				
			||||||
                    <f:facet name="header"> <h:outputText value="sname" /></f:facet>                
 | 
					                    <f:facet name="header"> <h:outputText value="sname" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.sname}"/>
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.sname}">
 | 
				
			||||||
 | 
					                        <f:validateLength minimum="3" maximum="20" />
 | 
				
			||||||
 | 
					                    </h:inputText>
 | 
				
			||||||
                </h:column>
 | 
					                </h:column>
 | 
				
			||||||
                <h:column> 
 | 
					                <h:column> 
 | 
				
			||||||
                    <f:facet name="header"> <h:outputText value="birthday" /></f:facet>                
 | 
					                    <f:facet name="header"> <h:outputText value="birthday" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <h:inputText disabled ="#{!supplier.modify}" value="#{supplier.birthday}"/>
 | 
					                    <h:inputText disabled ="#{!supplier.modify}" value="#{supplier.birthday}" validator="dateValidator"/>
 | 
				
			||||||
                </h:column>
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <h:column> 
 | 
					                <h:column> 
 | 
				
			||||||
                    <f:facet name="header"> <h:outputText value="status" /></f:facet>                
 | 
					                    <f:facet name="header"> <h:outputText value="status"/></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.status}"/>
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.status}" validator="numericValidator"/>
 | 
				
			||||||
                </h:column>
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <h:column> 
 | 
					                <h:column> 
 | 
				
			||||||
                    <f:facet name="header"> <h:outputText value="city" /></f:facet>                
 | 
					                    <f:facet name="header"> <h:outputText value="city" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.city}"/>
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.city}">
 | 
				
			||||||
 | 
					                        <f:validateLength minimum="3" maximum="20" />
 | 
				
			||||||
 | 
					                    </h:inputText>
 | 
				
			||||||
                </h:column>  
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -51,6 +56,9 @@
 | 
				
			|||||||
                                              value="#{supplier.modify}">
 | 
					                                              value="#{supplier.modify}">
 | 
				
			||||||
                    </h:selectBooleanCheckbox >
 | 
					                    </h:selectBooleanCheckbox >
 | 
				
			||||||
                </h:column>  
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					            <h:column>
 | 
				
			||||||
 | 
					                <h:commandButton value="Delete" action="#{supplierBean.}"
 | 
				
			||||||
 | 
					            </h:column>
 | 
				
			||||||
            </h:dataTable>
 | 
					            </h:dataTable>
 | 
				
			||||||
            <h:commandButton value="Save" action="#{supplierBean.saveFromUpdate()}" />
 | 
					            <h:commandButton value="Save" action="#{supplierBean.saveFromUpdate()}" />
 | 
				
			||||||
        </h:form>
 | 
					        </h:form>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,9 +12,11 @@ import java.util.List;
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author asdv5
 | 
					 * @author asdv5
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public interface DBase<T>
 | 
					public interface DBase<T> {
 | 
				
			||||||
{
 | 
					
 | 
				
			||||||
    List<T> listAll();
 | 
					    List<T> listAll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int update(T t) throws SQLException;
 | 
					    int update(T t) throws SQLException;
 | 
				
			||||||
          }
 | 
					    
 | 
				
			||||||
 | 
					    int delete(T t) throws SQLException;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,4 +88,10 @@ public class DatabaseManipulationParts implements DBase<Part>
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int delete(Part t) throws SQLException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,4 +89,10 @@ public class DatabaseManipulationSupplier implements DBase<Supplier>
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int delete(Supplier t) throws SQLException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>9.0-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
							
								
								
									
										88
									
								
								Semester 2/Assignments/SuppliersPartsDatabase_old/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								Semester 2/Assignments/SuppliersPartsDatabase_old/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>com.mycompany</groupId>
 | 
				
			||||||
 | 
					    <artifactId>SuppliersPartsDatabase</artifactId>
 | 
				
			||||||
 | 
					    <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>SuppliersPartsDatabase-1.0-SNAPSHOT</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <maven.compiler.source>1.8</maven.compiler.source>
 | 
				
			||||||
 | 
					        <maven.compiler.target>1.8</maven.compiler.target>
 | 
				
			||||||
 | 
					        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					        <jakartaee>9.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>com.mysql</groupId>
 | 
				
			||||||
 | 
					            <artifactId>mysql-connector-j</artifactId>
 | 
				
			||||||
 | 
					            <version>8.1.0</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>org.primefaces</groupId>
 | 
				
			||||||
 | 
					            <artifactId>primefaces</artifactId>
 | 
				
			||||||
 | 
					            <version>12.0.0</version>
 | 
				
			||||||
 | 
					            <classifier>jakarta</classifier>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>1.8</source>
 | 
				
			||||||
 | 
					                    <target>1.8</target>
 | 
				
			||||||
 | 
					                    <compilerArguments>
 | 
				
			||||||
 | 
					                        <endorseddirs>${endorsed.dir}</endorseddirs>
 | 
				
			||||||
 | 
					                    </compilerArguments>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.3</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-dependency-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.6</version>
 | 
				
			||||||
 | 
					                <executions>
 | 
				
			||||||
 | 
					                    <execution>
 | 
				
			||||||
 | 
					                        <phase>validate</phase>
 | 
				
			||||||
 | 
					                        <goals>
 | 
				
			||||||
 | 
					                            <goal>copy</goal>
 | 
				
			||||||
 | 
					                        </goals>
 | 
				
			||||||
 | 
					                        <configuration>
 | 
				
			||||||
 | 
					                            <outputDirectory>${endorsed.dir}</outputDirectory>
 | 
				
			||||||
 | 
					                            <silent>true</silent>
 | 
				
			||||||
 | 
					                            <artifactItems>
 | 
				
			||||||
 | 
					                                <artifactItem>
 | 
				
			||||||
 | 
					                                    <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					                                    <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					                                    <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					                                    <type>jar</type>
 | 
				
			||||||
 | 
					                                </artifactItem>
 | 
				
			||||||
 | 
					                            </artifactItems>
 | 
				
			||||||
 | 
					                        </configuration>
 | 
				
			||||||
 | 
					                    </execution>
 | 
				
			||||||
 | 
					                </executions>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package com.mycompany.supplierspartsdatabase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package com.mycompany.supplierspartsdatabase.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee9")
 | 
				
			||||||
 | 
					public class JakartaEE9Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.DBase;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.supplier.DatabaseManipulationSupplier;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.supplier.Supplier;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.SessionScoped;
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage;
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage.Severity;
 | 
				
			||||||
 | 
					import jakarta.faces.context.FacesContext;
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Named(value = "supplierBean")
 | 
				
			||||||
 | 
					@SessionScoped
 | 
				
			||||||
 | 
					public class SupplierBean implements Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    DBase dms = new DatabaseManipulationSupplier();
 | 
				
			||||||
 | 
					    List<Supplier> suppliers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public SupplierBean()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        suppliers = dms.listAll();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<Supplier> getSuppliers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return suppliers;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void saveFromUpdate()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int totalRowsUpdated = 0;
 | 
				
			||||||
 | 
					        for (Supplier s : this.suppliers)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (s.isModify())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    int rowsUpdated = this.dms.update(s);
 | 
				
			||||||
 | 
					                    if (rowsUpdated > 0)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        totalRowsUpdated += rowsUpdated;
 | 
				
			||||||
 | 
					                        s.setModify(false);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception e)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    String msg = ("Numbers of rows updated is 0.");
 | 
				
			||||||
 | 
					                    addMessage(msg, e.getMessage(), FacesMessage.SEVERITY_ERROR);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String msg = ("Numbers of rows updated: " + totalRowsUpdated);
 | 
				
			||||||
 | 
					        addMessage(msg, "no exception", FacesMessage.SEVERITY_INFO);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void addMessage(String summary, String detail, Severity severity)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        FacesMessage msg = new FacesMessage(severity, summary, detail);
 | 
				
			||||||
 | 
					        FacesContext.getCurrentInstance().addMessage(null, msg);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface DBase<T>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  List<T> listAll();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  int update( T t)
 | 
				
			||||||
 | 
					          throws SQLException;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,96 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class UtilitiesDatabase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					     public Connection connection( 
 | 
				
			||||||
 | 
					        String databaseName,
 | 
				
			||||||
 | 
					        String userName,
 | 
				
			||||||
 | 
					        String password,
 | 
				
			||||||
 | 
					        String URL2 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     ) //throws InstantiationException, IllegalAccessException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = null;
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					    Connection con;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					      public void closeDatabaseConnection( Connection con)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            if (con != null)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                con.close();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (SQLException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.out.println(e);
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					public static java.sql.Date stringDateToSqlDate(String sDate)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        java.util.Date date = null;
 | 
				
			||||||
 | 
					        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            date = sdf.parse(sDate);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (ParseException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        return new  java.sql.Date( date.getTime() );
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.part;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.DBase;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.UtilitiesDatabase;
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DatabaseManipulationPart implements DBase<Part>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<Part> listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        List<Part> tableParts = new ArrayList<Part>();
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            String table = "";
 | 
				
			||||||
 | 
					            ResultSet rs = null;
 | 
				
			||||||
 | 
					            String sqlStr = "SELECT  *  FROM part";
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            int row = 0;
 | 
				
			||||||
 | 
					            while (rs.next())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                String pNumber = rs.getString(1);
 | 
				
			||||||
 | 
					                String pName = rs.getString(2);
 | 
				
			||||||
 | 
					                String color = rs.getString(3) + " ";
 | 
				
			||||||
 | 
					                String city = rs.getString(4) + " ";
 | 
				
			||||||
 | 
					                Part part = new Part(pNumber, pName, color, city);
 | 
				
			||||||
 | 
					                tableParts.add(part);
 | 
				
			||||||
 | 
					                row++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new UtilitiesDatabase().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tableParts;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void main(String[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        DatabaseManipulationPart dmp = new DatabaseManipulationPart();
 | 
				
			||||||
 | 
					        System.out.println(dmp.listAll());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int update(Part t)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.part;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Part
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    private String pnumber;
 | 
				
			||||||
 | 
					    private String pname;
 | 
				
			||||||
 | 
					    private String color;
 | 
				
			||||||
 | 
					    private String city;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Part(String pnumber, String pname, String color, String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.pnumber = pnumber;
 | 
				
			||||||
 | 
					        this.pname = pname;
 | 
				
			||||||
 | 
					        this.color = color;
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getColor()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return color;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setColor(String color)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.color = color;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getCity()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setCity(String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getPname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return pname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setPname(String pname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.pname = pname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getPnumber()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return pnumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setPnumber(String pnumber)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.pnumber = pnumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String toString()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return "Part{" + "pnumber=" + pnumber + ", pname=" + pname + ", color=" + color + ", city=" + city + '}';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,140 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.supplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.DBase;
 | 
				
			||||||
 | 
					import edu.slcc.asdv.bl.UtilitiesDatabase;
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.ParameterMetaData;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DatabaseManipulationSupplier implements DBase<Supplier>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<Supplier> listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        List<Supplier> tableSuppliers = new ArrayList<Supplier>();
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            String table = "";
 | 
				
			||||||
 | 
					            ResultSet rs = null;
 | 
				
			||||||
 | 
					            String sqlStr = "SELECT  *  FROM supplier";
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            int row = 0;
 | 
				
			||||||
 | 
					            while (rs.next())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                String sNumber = rs.getString(1);
 | 
				
			||||||
 | 
					                String sName = rs.getString(2);
 | 
				
			||||||
 | 
					                String bdate = rs.getDate(3) + " ";
 | 
				
			||||||
 | 
					                int status = rs.getInt(4);
 | 
				
			||||||
 | 
					                String city = rs.getString(5) + " ";
 | 
				
			||||||
 | 
					                Supplier supplier = new Supplier(sNumber, sName, bdate, status, city);
 | 
				
			||||||
 | 
					                tableSuppliers.add(supplier);
 | 
				
			||||||
 | 
					                row++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new UtilitiesDatabase().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tableSuppliers;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int update(Supplier t)
 | 
				
			||||||
 | 
					            throws SQLException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new UtilitiesDatabase().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        int result = 0;
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?");
 | 
				
			||||||
 | 
					            updateSupplier.setString(1, t.getSnumber());
 | 
				
			||||||
 | 
					            updateSupplier.setString(2, t.getSname());     
 | 
				
			||||||
 | 
					            updateSupplier.setInt(3, t.getStatus());
 | 
				
			||||||
 | 
					            java.sql.Date bd = UtilitiesDatabase.stringDateToSqlDate(t.getBirthday());
 | 
				
			||||||
 | 
					            updateSupplier.setDate(4, bd);
 | 
				
			||||||
 | 
					            updateSupplier.setString(5, t.getCity());
 | 
				
			||||||
 | 
					            updateSupplier.setString(6, t.getSnumber());
 | 
				
			||||||
 | 
					            result = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (SQLException ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					            throw ex;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new UtilitiesDatabase().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					                throw sqle;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,110 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl.supplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author asdv5
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Supplier implements Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    private String snumber;
 | 
				
			||||||
 | 
					    private String sname;
 | 
				
			||||||
 | 
					    private String birthday;
 | 
				
			||||||
 | 
					    private int status;
 | 
				
			||||||
 | 
					    private String city;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private boolean modify;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isModify()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return modify;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setModify(boolean modify)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.modify = modify;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Supplier(String snumber, String sname, String birthday, int status, String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.snumber = snumber;
 | 
				
			||||||
 | 
					        this.sname = sname;
 | 
				
			||||||
 | 
					        this.birthday = birthday;
 | 
				
			||||||
 | 
					        this.status = status;
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					        this.modify = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getCity()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setCity(String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getStatus()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStatus(int status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.status = status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getBirthday()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBirthday(String birthday)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.birthday = birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSname(String sname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        System.out.println( sname);
 | 
				
			||||||
 | 
					        this.sname = sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSnumber()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        return snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSnumber(String snumber)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.snumber = snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String toString()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return "Supplier{" + "snumber=" + snumber + ", sname=" + sname + ", birthday=" + birthday + ", status=" + status + ", city=" + city + '}';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">
 | 
				
			||||||
 | 
					    <context-param>
 | 
				
			||||||
 | 
					        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
 | 
				
			||||||
 | 
					        <param-value>Development</param-value>
 | 
				
			||||||
 | 
					    </context-param>
 | 
				
			||||||
 | 
					    <servlet>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
 | 
				
			||||||
 | 
					        <load-on-startup>1</load-on-startup>
 | 
				
			||||||
 | 
					    </servlet>
 | 
				
			||||||
 | 
					    <servlet-mapping>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <url-pattern>/faces/*</url-pattern>
 | 
				
			||||||
 | 
					    </servlet-mapping>
 | 
				
			||||||
 | 
					    <session-config>
 | 
				
			||||||
 | 
					        <session-timeout>
 | 
				
			||||||
 | 
					            30
 | 
				
			||||||
 | 
					        </session-timeout>
 | 
				
			||||||
 | 
					    </session-config>
 | 
				
			||||||
 | 
					    <welcome-file-list>
 | 
				
			||||||
 | 
					        <welcome-file>faces/supplier.xhtml</welcome-file>
 | 
				
			||||||
 | 
					    </welcome-file-list>
 | 
				
			||||||
 | 
					</web-app>
 | 
				
			||||||
@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <h:outputStylesheet library="css" name="styles.css"/>
 | 
				
			||||||
 | 
					        <title>Supplier Parts DB</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h1>   Suppliers-Parts Database </h1>
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            <h:panelGrid columns="2">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier ID:"/>
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.snumber}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="8">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier Name"/>
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.sname}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Status" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.status}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Birthday" />
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.birthday}"/> 
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="City" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.city}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="6">
 | 
				
			||||||
 | 
					                <h:commandButton styleClass="button" value="View Supplier" action="#{suppliers.viewSupplier()}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Insert Supplier" action="#{suppliers.insertSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Update Supplier" action="#{suppliers.updateSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Delete Supplier" action="#{suppliers.deleteSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="List All Suppliers" action="#{suppliers.listAll}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Clear" action="#{suppliers.clear}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid>
 | 
				
			||||||
 | 
					                <h:outputText escape="false" style="color:green" 
 | 
				
			||||||
 | 
					                              value="#{suppliers.result}">
 | 
				
			||||||
 | 
					                </h:outputText>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					.body {
 | 
				
			||||||
 | 
					   background: #eee;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button {
 | 
				
			||||||
 | 
						margin: 10px;
 | 
				
			||||||
 | 
						border-left: thin solid darkGray;
 | 
				
			||||||
 | 
						border-bottom: thin solid darkGray;
 | 
				
			||||||
 | 
						border-top: thin solid lightGray;
 | 
				
			||||||
 | 
						border-right: thin solid lightGray;
 | 
				
			||||||
 | 
					        color: #777;
 | 
				
			||||||
 | 
					        background: #A7C942;
 | 
				
			||||||
 | 
					        font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					        border-radius: 20%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					h1 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   vertical-align: top;
 | 
				
			||||||
 | 
					   text-align: middle;
 | 
				
			||||||
 | 
					   font-style: italic;
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 2em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.label
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 0.8em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.leftImage {
 | 
				
			||||||
 | 
					   float: left;
 | 
				
			||||||
 | 
					   margin-right: 1em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.backLink {
 | 
				
			||||||
 | 
						font-style: italic;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tableHeader {
 | 
				
			||||||
 | 
					    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
 | 
				
			||||||
 | 
					    border-collapse:collapse;
 | 
				
			||||||
 | 
					    font-size:1.1em;
 | 
				
			||||||
 | 
					    text-align:left;
 | 
				
			||||||
 | 
					    padding-top:5px;
 | 
				
			||||||
 | 
					    padding-bottom:4px;
 | 
				
			||||||
 | 
					    background-color:#A7C942;
 | 
				
			||||||
 | 
					    color:white;
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.oddTableRow {
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.evenTableRow {
 | 
				
			||||||
 | 
					    background-color: #eeeeee;
 | 
				
			||||||
 | 
					    font-size:1em;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    padding:3px 7px 2px 7px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    color:#000000;
 | 
				
			||||||
 | 
					    background-color:#EAF2D3;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.table {
 | 
				
			||||||
 | 
					    border:1px solid green;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,58 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html"
 | 
				
			||||||
 | 
					      xmlns:f="http://xmlns.jcp.org/jsf/core"
 | 
				
			||||||
 | 
					      xmlns:p="http://primefaces.org/ui">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					         <p:growl id="globalgrowl" showDetail="false" showSummary="true"  life="2000"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:dataTable  var="supplier"  
 | 
				
			||||||
 | 
					                          value="#{supplierBean.getSuppliers()}"  >
 | 
				
			||||||
 | 
					            <f:facet name="header"> <h:outputText value="Suppliers Table" style="font-size: 1.2em"/></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="snumber" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="true" value="#{supplier.snumber}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="sname" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.sname}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="birthday" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}" value="#{supplier.birthday}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="status" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.status}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="city" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.city}"/>
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="update" /></f:facet>                
 | 
				
			||||||
 | 
					                    <h:selectBooleanCheckbox  onclick="submit()"
 | 
				
			||||||
 | 
					                                              value="#{supplier.modify}">
 | 
				
			||||||
 | 
					                    </h:selectBooleanCheckbox >
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					            </h:dataTable>
 | 
				
			||||||
 | 
					            <h:commandButton value="Save" action="#{supplierBean.saveFromUpdate()}" />
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
							
								
								
									
										77
									
								
								Semester 2/Assignments/SwingTest/suppliers_parts/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								Semester 2/Assignments/SwingTest/suppliers_parts/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>edu.slcc.asdv</groupId>
 | 
				
			||||||
 | 
					    <artifactId>suppliers_parts</artifactId>
 | 
				
			||||||
 | 
					    <version>1</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>suppliers_parts-1</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <maven.compiler.source>11</maven.compiler.source>
 | 
				
			||||||
 | 
					        <maven.compiler.target>11</maven.compiler.target>
 | 
				
			||||||
 | 
					        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					        <jakartaee>10.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.8.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>11</source>
 | 
				
			||||||
 | 
					                    <target>11</target>
 | 
				
			||||||
 | 
					                    <compilerArguments>
 | 
				
			||||||
 | 
					                        <endorseddirs>${endorsed.dir}</endorseddirs>
 | 
				
			||||||
 | 
					                    </compilerArguments>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.3</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-dependency-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.6</version>
 | 
				
			||||||
 | 
					                <executions>
 | 
				
			||||||
 | 
					                    <execution>
 | 
				
			||||||
 | 
					                        <phase>validate</phase>
 | 
				
			||||||
 | 
					                        <goals>
 | 
				
			||||||
 | 
					                            <goal>copy</goal>
 | 
				
			||||||
 | 
					                        </goals>
 | 
				
			||||||
 | 
					                        <configuration>
 | 
				
			||||||
 | 
					                            <outputDirectory>${endorsed.dir}</outputDirectory>
 | 
				
			||||||
 | 
					                            <silent>true</silent>
 | 
				
			||||||
 | 
					                            <artifactItems>
 | 
				
			||||||
 | 
					                                <artifactItem>
 | 
				
			||||||
 | 
					                                    <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					                                    <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					                                    <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					                                    <type>jar</type>
 | 
				
			||||||
 | 
					                                </artifactItem>
 | 
				
			||||||
 | 
					                            </artifactItems>
 | 
				
			||||||
 | 
					                        </configuration>
 | 
				
			||||||
 | 
					                    </execution>
 | 
				
			||||||
 | 
					                </executions>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,466 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.ApplicationScoped;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author a. v. markou
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Named(value = "suppliers")
 | 
				
			||||||
 | 
					@ApplicationScoped
 | 
				
			||||||
 | 
					public class Suppliers implements Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String snumber = "";
 | 
				
			||||||
 | 
					    String sname = "";
 | 
				
			||||||
 | 
					    int status = 0;
 | 
				
			||||||
 | 
					    String birthday = "";
 | 
				
			||||||
 | 
					    String city = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String result = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Suppliers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        connection();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSnumber()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSnumber(String snumber)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.snumber = snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSname(String sname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.sname = sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getStatus()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStatus(int status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.status = status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getBirthday()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBirthday(String birthday)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.birthday = birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getCity()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setCity(String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getConnectionResponse()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        if (con != null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            return "<p style=\"color:green\">Connection succesfull! <br />";
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            connection();
 | 
				
			||||||
 | 
					            return "<p style=\"color:red\">Connection failed! <br />";
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					 public static Connection getConnection(String databaseName, String userName, String password) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Connection con = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					        catch (Exception e) {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    private Connection connection() //throws InstantiationException, IllegalAccessException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void clear()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        status = 0;
 | 
				
			||||||
 | 
					        snumber = "";
 | 
				
			||||||
 | 
					        sname = "";
 | 
				
			||||||
 | 
					        birthday = "";
 | 
				
			||||||
 | 
					        city = "";
 | 
				
			||||||
 | 
					        result = "";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        String table = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT  *  FROM supplier";
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            while (rs.next())
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                String sNumber = rs.getString(1) + " ";
 | 
				
			||||||
 | 
					                String sName = rs.getString(2) + " ";
 | 
				
			||||||
 | 
					                String status = rs.getInt(4) + " ";
 | 
				
			||||||
 | 
					                String bdate = rs.getDate(3) + " ";
 | 
				
			||||||
 | 
					                String city = rs.getString(5) + " ";
 | 
				
			||||||
 | 
					                table += sNumber + sName + bdate + status + city + "</br>";
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                closeDatabaseConnection(  con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqle){ sqle.printStackTrace(); }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        result = table;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void viewSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        String ret = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT *  FROM supplier WHERE snumber=?";
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            if (rs.next())
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                this.snumber = rs.getString("snumber");
 | 
				
			||||||
 | 
					                ret += this.snumber + " ";
 | 
				
			||||||
 | 
					                this.sname = rs.getString("sname");
 | 
				
			||||||
 | 
					                ret += this.sname + " ";
 | 
				
			||||||
 | 
					                this.status = rs.getInt("status");
 | 
				
			||||||
 | 
					                ret += this.status + " ";
 | 
				
			||||||
 | 
					                this.city = rs.getString("city");
 | 
				
			||||||
 | 
					                ret += this.city + " ";
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                Object bDate = rs.getObject("birthday");
 | 
				
			||||||
 | 
					                this.birthday = bDate.toString();
 | 
				
			||||||
 | 
					                ret += this.birthday;                 
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					                ret = this.snumber + " doesn't exist.";
 | 
				
			||||||
 | 
					           }
 | 
				
			||||||
 | 
					        catch (Exception ex){ex.printStackTrace();}
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqle){ sqle.printStackTrace();}
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        this.result = ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void updateSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            updateSupplier.setString(1, snumber);
 | 
				
			||||||
 | 
					            updateSupplier.setString(2, sname);
 | 
				
			||||||
 | 
					            updateSupplier.setInt(3, status);
 | 
				
			||||||
 | 
					             java.sql.Date  bd = stringDateToSqlDate(this.birthday);
 | 
				
			||||||
 | 
					            updateSupplier.setDate(4, bd );
 | 
				
			||||||
 | 
					            updateSupplier.setString(5, city);
 | 
				
			||||||
 | 
					            updateSupplier.setString(6, snumber);
 | 
				
			||||||
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqlee)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void deleteSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        int rowsAffected = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            String query = "DELETE FROM supplier WHERE snumber=? ";
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(query);
 | 
				
			||||||
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
 | 
					            rowsAffected = ps.executeUpdate();
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + rowsAffected;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqlee)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void insertSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					       Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "INSERT INTO supplier (snumber, sname, status, birthday, city ) "
 | 
				
			||||||
 | 
					                    + "VALUES ( ?, ?, ? , ? ,? )");
 | 
				
			||||||
 | 
					            updateSupplier.setString(1, snumber);
 | 
				
			||||||
 | 
					            updateSupplier.setString(2, sname);
 | 
				
			||||||
 | 
					            updateSupplier.setInt(3, status);
 | 
				
			||||||
 | 
					            java.sql.Date sqlDate = stringDateToSqlDate(birthday);
 | 
				
			||||||
 | 
					            updateSupplier.setDate(4, sqlDate);
 | 
				
			||||||
 | 
					            updateSupplier.setString(5, city);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					            result = ex.toString();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException e)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                System.err.println(e.toString());
 | 
				
			||||||
 | 
					                result = e.toString();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					private java.sql.Date stringDateToSqlDate(String sDate)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        java.util.Date date = null;
 | 
				
			||||||
 | 
					        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            date = sdf.parse(sDate);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (ParseException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        return new  java.sql.Date( date.getTime() );
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getResult()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return "<p style=\"color:green\">Suppliers <br />" + result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void closeDatabaseConnection( Connection con)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            if (con != null)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                con.close();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (SQLException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            result = e.toString();
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.suppliers_parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.suppliers_parts.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee10")
 | 
				
			||||||
 | 
					public class JakartaEE10Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h:panelGrid columns="2">
 | 
				
			||||||
 | 
					                <h:outputLabel value="table name "/>
 | 
				
			||||||
 | 
					                <h:inputText value="#{queryBean.tableName}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="SELECT * FROM table" action="#{queryBean.queries()}"/>
 | 
				
			||||||
 | 
					                <h:outputText escape="false" style="color:green" value="#{queryBean.table}"> </h:outputText>  
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
 | 
				
			||||||
 | 
					    <context-param>
 | 
				
			||||||
 | 
					        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
 | 
				
			||||||
 | 
					        <param-value>Development</param-value>
 | 
				
			||||||
 | 
					    </context-param>
 | 
				
			||||||
 | 
					    <servlet>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
 | 
				
			||||||
 | 
					        <load-on-startup>1</load-on-startup>
 | 
				
			||||||
 | 
					    </servlet>
 | 
				
			||||||
 | 
					    <servlet-mapping>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <url-pattern>/faces/*</url-pattern>
 | 
				
			||||||
 | 
					    </servlet-mapping>
 | 
				
			||||||
 | 
					    <session-config>
 | 
				
			||||||
 | 
					        <session-timeout>
 | 
				
			||||||
 | 
					            30
 | 
				
			||||||
 | 
					        </session-timeout>
 | 
				
			||||||
 | 
					    </session-config>
 | 
				
			||||||
 | 
					    <welcome-file-list>
 | 
				
			||||||
 | 
					        <welcome-file>faces/index.xhtml</welcome-file>
 | 
				
			||||||
 | 
					    </welcome-file-list>
 | 
				
			||||||
 | 
					</web-app>
 | 
				
			||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html"
 | 
				
			||||||
 | 
					      xmlns:f="http://xmlns.jcp.org/jsf/core">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <h:outputStylesheet library="css" name="styles.css"/>
 | 
				
			||||||
 | 
					        <title>Supplier Parts DB</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h1>   Suppliers-Parts Database </h1>
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            <h:panelGrid columns="2">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier ID:"/>
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.snumber}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="8">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier Name"/>
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.sname}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Status" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.status}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Birthday" />
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.birthday}"/> 
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="City" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.city}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="6">
 | 
				
			||||||
 | 
					                <h:commandButton styleClass="button" value="View Supplier" action="#{suppliers.viewSupplier()}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Insert Supplier" action="#{suppliers.insertSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Update Supplier" action="#{suppliers.updateSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Delete Supplier" action="#{suppliers.deleteSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="List All Suppliers" action="#{suppliers.listAll}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Clear" action="#{suppliers.clear}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid>
 | 
				
			||||||
 | 
					                <h:outputText escape="false" style="color:green" 
 | 
				
			||||||
 | 
					                              value="#{suppliers.result}">
 | 
				
			||||||
 | 
					                </h:outputText>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					.body {
 | 
				
			||||||
 | 
					   background: #eee;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button {
 | 
				
			||||||
 | 
						margin: 10px;
 | 
				
			||||||
 | 
						border-left: thin solid darkGray;
 | 
				
			||||||
 | 
						border-bottom: thin solid darkGray;
 | 
				
			||||||
 | 
						border-top: thin solid lightGray;
 | 
				
			||||||
 | 
						border-right: thin solid lightGray;
 | 
				
			||||||
 | 
					        color: #777;
 | 
				
			||||||
 | 
					        background: #A7C942;
 | 
				
			||||||
 | 
					        font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					        border-radius: 20%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					h1 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   vertical-align: top;
 | 
				
			||||||
 | 
					   text-align: middle;
 | 
				
			||||||
 | 
					   font-style: italic;
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 2em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.label
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 0.8em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.leftImage {
 | 
				
			||||||
 | 
					   float: left;
 | 
				
			||||||
 | 
					   margin-right: 1em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.backLink {
 | 
				
			||||||
 | 
						font-style: italic;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tableHeader {
 | 
				
			||||||
 | 
					    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
 | 
				
			||||||
 | 
					    border-collapse:collapse;
 | 
				
			||||||
 | 
					    font-size:1.1em;
 | 
				
			||||||
 | 
					    text-align:left;
 | 
				
			||||||
 | 
					    padding-top:5px;
 | 
				
			||||||
 | 
					    padding-bottom:4px;
 | 
				
			||||||
 | 
					    background-color:#A7C942;
 | 
				
			||||||
 | 
					    color:white;
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.oddTableRow {
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.evenTableRow {
 | 
				
			||||||
 | 
					    background-color: #eeeeee;
 | 
				
			||||||
 | 
					    font-size:1em;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    padding:3px 7px 2px 7px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    color:#000000;
 | 
				
			||||||
 | 
					    background-color:#EAF2D3;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.table {
 | 
				
			||||||
 | 
					    border:1px solid green;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -16,12 +16,5 @@ Any value defined here will override the pom.xml file value but is only applicab
 | 
				
			|||||||
        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.less_2e_mappings>/less:/css</org-netbeans-modules-css-prep.less_2e_mappings>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.less_2e_enabled>false</org-netbeans-modules-css-prep.less_2e_enabled>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.sass_2e_enabled>false</org-netbeans-modules-css-prep.sass_2e_enabled>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.sass_2e_compiler_2e_options/>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
 | 
					 | 
				
			||||||
        <org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
 | 
					 | 
				
			||||||
    </properties>
 | 
					    </properties>
 | 
				
			||||||
</project-shared-configuration>
 | 
					</project-shared-configuration>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,11 +23,6 @@
 | 
				
			|||||||
            <version>${jakartaee}</version>
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
            <scope>provided</scope>
 | 
					            <scope>provided</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>mysql</groupId>
 | 
					 | 
				
			||||||
            <artifactId>mysql-connector-java</artifactId>
 | 
					 | 
				
			||||||
            <version>8.0.33</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
    </dependencies>
 | 
					    </dependencies>
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    <build>
 | 
					    <build>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
package edu.slcc.asdv.bl;
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -12,4 +13,7 @@ import java.util.List;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public interface DBase<T> {
 | 
					public interface DBase<T> {
 | 
				
			||||||
   List<? extends List<T>> listAll();
 | 
					   List<? extends List<T>> listAll();
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					   int delete( T t)
 | 
				
			||||||
 | 
					          throws SQLException;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,6 @@ import java.sql.ResultSet;
 | 
				
			|||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
import java.text.ParseException;
 | 
					import java.text.ParseException;
 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.Date;
 | 
					 | 
				
			||||||
import jakarta.enterprise.context.ApplicationScoped;
 | 
					import jakarta.enterprise.context.ApplicationScoped;
 | 
				
			||||||
import jakarta.inject.Named;
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -18,17 +17,17 @@ import jakarta.inject.Named;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
@Named(value = "suppliers")
 | 
					@Named(value = "suppliers")
 | 
				
			||||||
@ApplicationScoped
 | 
					@ApplicationScoped
 | 
				
			||||||
public class Suppliers implements Serializable {
 | 
					public class Suppliers implements Serializable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    String snumber = "";
 | 
					    String snumber = "";
 | 
				
			||||||
    String sname = "";
 | 
					    String sname = "";
 | 
				
			||||||
    int status = 0;
 | 
					    int status = 0;
 | 
				
			||||||
    String birthday = "";
 | 
					    String birthday = "";
 | 
				
			||||||
    String city = "";
 | 
					    String city = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    String result = "";
 | 
					    String result = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    public Suppliers()
 | 
					    public Suppliers()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        connection();
 | 
					        connection();
 | 
				
			||||||
@@ -87,46 +86,83 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    public String getConnectionResponse()
 | 
					    public String getConnectionResponse()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Connection con = connection();
 | 
					        Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        if (con != null) {
 | 
					        if (con != null)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            return "<p style=\"color:green\">Connection succesfull! <br />";
 | 
					            return "<p style=\"color:green\">Connection succesfull! <br />";
 | 
				
			||||||
        } else {
 | 
					          }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            connection();
 | 
					            connection();
 | 
				
			||||||
            return "<p style=\"color:red\">Connection failed! <br />";
 | 
					            return "<p style=\"color:red\">Connection failed! <br />";
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 public static Connection getConnection(String databaseName, String userName, String password) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Connection connection() //throws InstantiationException, IllegalAccessException
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        /*
 | 
					 | 
				
			||||||
                String databaseName = "suppliers_parts_23";
 | 
					 | 
				
			||||||
                String userName = "admin";
 | 
					 | 
				
			||||||
                String password = "RangerDog01!";
 | 
					 | 
				
			||||||
        String URL2 = "com.mysql.jdbc.Driver";
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
                Connection con = null;
 | 
					 | 
				
			||||||
         */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Connection con = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {// Load Sun's jdbc driver
 | 
					        try {// Load Sun's jdbc driver
 | 
				
			||||||
            Class.forName(URL2).newInstance();
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
            System.out.println("JDBC Driver loaded!");
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
        } catch (Exception e) // driver not found
 | 
					        } 
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					        catch (Exception e) {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    private Connection connection() //throws InstantiationException, IllegalAccessException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					        String userName = "root";
 | 
				
			||||||
 | 
					        String password = "root";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            System.err.println("Unable to load database driver");
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
            System.err.println("Details : " + e);
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        String ip = "localhost"; //internet connection
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
        String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?useSSL=false";
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
        System.out.println(url);
 | 
					        try
 | 
				
			||||||
        try {
 | 
					          {
 | 
				
			||||||
            con = DriverManager.getConnection(url, userName, password);
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
            con.setReadOnly(false);
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            System.err.println(e.toString());
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@@ -134,6 +170,7 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
        return con;
 | 
					        return con;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void clear()
 | 
					    public void clear()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        status = 0;
 | 
					        status = 0;
 | 
				
			||||||
@@ -147,41 +184,47 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    public void listAll()
 | 
					    public void listAll()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Connection con = connection();
 | 
					        Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
            return;
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        String table = "";
 | 
					        String table = "";
 | 
				
			||||||
        PreparedStatement ps = null;
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
        ResultSet rs = null;
 | 
					        ResultSet rs = null;
 | 
				
			||||||
        String sqlStr = "SELECT  *  FROM supplier";
 | 
					        String sqlStr = "SELECT  *  FROM supplier";
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            //prepare statement
 | 
					            //prepare statement
 | 
				
			||||||
            ps = con.prepareStatement(sqlStr);
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
            //execute
 | 
					            //execute
 | 
				
			||||||
            rs = ps.executeQuery();
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
            int row = 0;
 | 
					            while (rs.next())
 | 
				
			||||||
            while (rs.next()) {
 | 
					              {
 | 
				
			||||||
                String sNumber = rs.getString(1) + " ";
 | 
					                String sNumber = rs.getString(1) + " ";
 | 
				
			||||||
                String sName = rs.getString(2) + " ";
 | 
					                String sName = rs.getString(2) + " ";
 | 
				
			||||||
                String bdate = rs.getDate(3) + " ";
 | 
					 | 
				
			||||||
                String status = rs.getInt(4) + " ";
 | 
					                String status = rs.getInt(4) + " ";
 | 
				
			||||||
 | 
					                String bdate = rs.getDate(3) + " ";
 | 
				
			||||||
                String city = rs.getString(5) + " ";
 | 
					                String city = rs.getString(5) + " ";
 | 
				
			||||||
                table += sNumber + sName + bdate + status + city + "</br>";
 | 
					                table += sNumber + sName + bdate + status + city + "</br>";
 | 
				
			||||||
                row++;
 | 
					 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            ex.printStackTrace();
 | 
					            ex.printStackTrace();
 | 
				
			||||||
        } finally {
 | 
					          }
 | 
				
			||||||
            try {
 | 
					        finally
 | 
				
			||||||
                closeDatabaseConnection(con);
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                closeDatabaseConnection(  con);
 | 
				
			||||||
                // close the resources 
 | 
					                // close the resources 
 | 
				
			||||||
                if (ps != null) {
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
                    ps.close();
 | 
					                    ps.close();
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
            } catch (SQLException sqle) {
 | 
					 | 
				
			||||||
                sqle.printStackTrace();
 | 
					 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqle){ sqle.printStackTrace(); }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        result = table;
 | 
					        result = table;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -189,21 +232,24 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    public void viewSupplier()
 | 
					    public void viewSupplier()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Connection con = connection();
 | 
					        Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
            return;
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        String ret = "";
 | 
					        String ret = "";
 | 
				
			||||||
        PreparedStatement ps = null;
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
        ResultSet rs = null;
 | 
					        ResultSet rs = null;
 | 
				
			||||||
        String sqlStr = "SELECT snumber, sname, status, city, birthday  FROM supplier WHERE snumber=?";
 | 
					        String sqlStr = "SELECT *  FROM supplier WHERE snumber=?";
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            //prepare statement
 | 
					            //prepare statement
 | 
				
			||||||
            ps = con.prepareStatement(sqlStr);
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
            ps.setString(1, snumber);
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
            //execute
 | 
					            //execute
 | 
				
			||||||
            rs = ps.executeQuery();
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
            if (rs.next()) {
 | 
					            if (rs.next())
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                this.snumber = rs.getString("snumber");
 | 
					                this.snumber = rs.getString("snumber");
 | 
				
			||||||
                ret += this.snumber + " ";
 | 
					                ret += this.snumber + " ";
 | 
				
			||||||
                this.sname = rs.getString("sname");
 | 
					                this.sname = rs.getString("sname");
 | 
				
			||||||
@@ -216,20 +262,20 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
                Object bDate = rs.getObject("birthday");
 | 
					                Object bDate = rs.getObject("birthday");
 | 
				
			||||||
                this.birthday = bDate.toString();
 | 
					                this.birthday = bDate.toString();
 | 
				
			||||||
                ret += this.birthday;                 
 | 
					                ret += this.birthday;                 
 | 
				
			||||||
            } else {
 | 
					              }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
                ret = this.snumber + " doesn't exist.";
 | 
					                ret = this.snumber + " doesn't exist.";
 | 
				
			||||||
           }
 | 
					           }
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					        catch (Exception ex){ex.printStackTrace();}
 | 
				
			||||||
            ex.printStackTrace();
 | 
					        finally
 | 
				
			||||||
        } finally {
 | 
					          {
 | 
				
			||||||
            try {
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                this.closeDatabaseConnection(con);
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
                if (ps != null) {
 | 
					                if (ps != null)
 | 
				
			||||||
                    ps.close();
 | 
					                    ps.close();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            } catch (SQLException sqle) {
 | 
					            catch (SQLException sqle){ sqle.printStackTrace();}
 | 
				
			||||||
                sqle.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        this.result = ret;
 | 
					        this.result = ret;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -237,38 +283,49 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    public void updateSupplier()
 | 
					    public void updateSupplier()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Connection con = connection();
 | 
					        Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
            return;
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        PreparedStatement updateSupplier = null;
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            updateSupplier = con.prepareStatement(
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
                    "UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?");
 | 
					                    "UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            updateSupplier.setString(1, snumber);
 | 
					            updateSupplier.setString(1, snumber);
 | 
				
			||||||
            updateSupplier.setString(2, sname);
 | 
					            updateSupplier.setString(2, sname);
 | 
				
			||||||
            updateSupplier.setInt(3, status);
 | 
					            updateSupplier.setInt(3, status);
 | 
				
			||||||
             java.sql.Date  bd = stringDateToSqlDate(this.birthday);
 | 
					             java.sql.Date  bd = stringDateToSqlDate(this.birthday);
 | 
				
			||||||
            updateSupplier.setDate(4, bd);
 | 
					            updateSupplier.setDate(4, bd );
 | 
				
			||||||
            updateSupplier.setString(5, city);
 | 
					            updateSupplier.setString(5, city);
 | 
				
			||||||
            updateSupplier.setString(6, snumber);
 | 
					            updateSupplier.setString(6, snumber);
 | 
				
			||||||
            int updateCount = updateSupplier.executeUpdate();
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            result = "number of rows affected: " + updateCount;
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            System.err.println(ex.toString());
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
        } finally {
 | 
					          }
 | 
				
			||||||
            try {
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                this.closeDatabaseConnection(con);
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
                // close the resources 
 | 
					                // close the resources 
 | 
				
			||||||
                if (updateSupplier != null) {
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
                    updateSupplier.close();
 | 
					                    updateSupplier.close();
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } catch (SQLException sqlee) {
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqlee)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                sqlee.printStackTrace();
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@@ -278,30 +335,40 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        Connection con = connection();
 | 
					        Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
            return;
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        PreparedStatement ps = null;
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
        int rowsAffected = -1;
 | 
					        int rowsAffected = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            String query = "DELETE FROM supplier WHERE snumber=? ";
 | 
					            String query = "DELETE FROM supplier WHERE snumber=? ";
 | 
				
			||||||
            ps = con.prepareStatement(query);
 | 
					            ps = con.prepareStatement(query);
 | 
				
			||||||
            ps.setString(1, snumber);
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
            rowsAffected = ps.executeUpdate();
 | 
					            rowsAffected = ps.executeUpdate();
 | 
				
			||||||
            result = "number of rows affected: " + rowsAffected;
 | 
					            result = "number of rows affected: " + rowsAffected;
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            System.err.println(ex.toString());
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
        } finally {
 | 
					          }
 | 
				
			||||||
            try {
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                this.closeDatabaseConnection(con);
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
                // close the resources 
 | 
					                // close the resources 
 | 
				
			||||||
                if (ps != null) {
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
                    ps.close();
 | 
					                    ps.close();
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } catch (SQLException sqlee) {
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException sqlee)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                sqlee.printStackTrace();
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@@ -310,12 +377,14 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
    public void insertSupplier()
 | 
					    public void insertSupplier()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
       Connection con = connection();
 | 
					       Connection con = connection();
 | 
				
			||||||
        if (con == null) {
 | 
					        if (con == null)
 | 
				
			||||||
            result = "cannot connect to database";
 | 
					          {
 | 
				
			||||||
            return;
 | 
					            result = "cannot connect to database" ;
 | 
				
			||||||
 | 
					            return ;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        PreparedStatement updateSupplier = null;
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            updateSupplier = con.prepareStatement(
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
                    "INSERT INTO supplier (snumber, sname, status, birthday, city ) "
 | 
					                    "INSERT INTO supplier (snumber, sname, status, birthday, city ) "
 | 
				
			||||||
                    + "VALUES ( ?, ?, ? , ? ,? )");
 | 
					                    + "VALUES ( ?, ?, ? , ? ,? )");
 | 
				
			||||||
@@ -329,34 +398,44 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
            int updateCount = updateSupplier.executeUpdate();
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            result = "number of rows affected: " + updateCount;
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
        } catch (Exception ex) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            System.err.println(ex.toString());
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
            result = ex.toString();
 | 
					            result = ex.toString();
 | 
				
			||||||
        } finally {
 | 
					          }
 | 
				
			||||||
            try {
 | 
					        finally
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                this.closeDatabaseConnection(con);
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
                // close the resources 
 | 
					                // close the resources 
 | 
				
			||||||
                if (updateSupplier != null) {
 | 
					                if (updateSupplier != null)
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
                    updateSupplier.close();
 | 
					                    updateSupplier.close();
 | 
				
			||||||
                  }
 | 
					                  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } catch (SQLException e) {
 | 
					              }
 | 
				
			||||||
 | 
					            catch (SQLException e)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
                System.err.println(e.toString());
 | 
					                System.err.println(e.toString());
 | 
				
			||||||
                result = e.toString();
 | 
					                result = e.toString();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					private java.sql.Date stringDateToSqlDate(String sDate)
 | 
				
			||||||
    private java.sql.Date stringDateToSqlDate(String sDate)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        java.util.Date date = null;
 | 
					        java.util.Date date = null;
 | 
				
			||||||
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
					        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
				
			||||||
        try {
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            date = sdf.parse(sDate);
 | 
					            date = sdf.parse(sDate);
 | 
				
			||||||
        } catch (ParseException e) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (ParseException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        return new java.sql.Date(date.getTime());
 | 
					        return new  java.sql.Date( date.getTime() );
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -366,13 +445,19 @@ public class Suppliers implements Serializable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void closeDatabaseConnection(Connection con)
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void closeDatabaseConnection( Connection con)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            if (con != null)
 | 
				
			||||||
              {
 | 
					              {
 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            if (con != null) {
 | 
					 | 
				
			||||||
                con.close();
 | 
					                con.close();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
        } catch (SQLException e) {
 | 
					          }
 | 
				
			||||||
 | 
					        catch (SQLException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
            result = e.toString();
 | 
					            result = e.toString();
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
					 | 
				
			||||||
<!--
 | 
					<!--
 | 
				
			||||||
    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -15,6 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
<glassfish-web-app error-url="">
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
  <class-loader delegate="true"/>
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
  <jsp-config>
 | 
					  <jsp-config>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.less_2e_mappings>/less:/css</org-netbeans-modules-css-prep.less_2e_mappings>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.less_2e_enabled>false</org-netbeans-modules-css-prep.less_2e_enabled>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.sass_2e_enabled>false</org-netbeans-modules-css-prep.sass_2e_enabled>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.sass_2e_compiler_2e_options/>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
							
								
								
									
										82
									
								
								Semester 2/Assignments/suppliers_parts_old/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								Semester 2/Assignments/suppliers_parts_old/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>edu.slcc.asdv</groupId>
 | 
				
			||||||
 | 
					    <artifactId>suppliers_parts</artifactId>
 | 
				
			||||||
 | 
					    <version>1</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>suppliers_parts-1</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <maven.compiler.source>11</maven.compiler.source>
 | 
				
			||||||
 | 
					        <maven.compiler.target>11</maven.compiler.target>
 | 
				
			||||||
 | 
					        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					        <jakartaee>10.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>mysql</groupId>
 | 
				
			||||||
 | 
					            <artifactId>mysql-connector-java</artifactId>
 | 
				
			||||||
 | 
					            <version>8.0.33</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.8.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>11</source>
 | 
				
			||||||
 | 
					                    <target>11</target>
 | 
				
			||||||
 | 
					                    <compilerArguments>
 | 
				
			||||||
 | 
					                        <endorseddirs>${endorsed.dir}</endorseddirs>
 | 
				
			||||||
 | 
					                    </compilerArguments>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.3</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <failOnMissingWebXml>false</failOnMissingWebXml>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-dependency-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>2.6</version>
 | 
				
			||||||
 | 
					                <executions>
 | 
				
			||||||
 | 
					                    <execution>
 | 
				
			||||||
 | 
					                        <phase>validate</phase>
 | 
				
			||||||
 | 
					                        <goals>
 | 
				
			||||||
 | 
					                            <goal>copy</goal>
 | 
				
			||||||
 | 
					                        </goals>
 | 
				
			||||||
 | 
					                        <configuration>
 | 
				
			||||||
 | 
					                            <outputDirectory>${endorsed.dir}</outputDirectory>
 | 
				
			||||||
 | 
					                            <silent>true</silent>
 | 
				
			||||||
 | 
					                            <artifactItems>
 | 
				
			||||||
 | 
					                                <artifactItem>
 | 
				
			||||||
 | 
					                                    <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					                                    <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					                                    <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					                                    <type>jar</type>
 | 
				
			||||||
 | 
					                                </artifactItem>
 | 
				
			||||||
 | 
					                            </artifactItems>
 | 
				
			||||||
 | 
					                        </configuration>
 | 
				
			||||||
 | 
					                    </execution>
 | 
				
			||||||
 | 
					                </executions>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface DBase<T> {
 | 
				
			||||||
 | 
					   List<? extends List<T>> listAll();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,109 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DatabaseManipulationSupplier implements DBase<Supplier> {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<List<Supplier>> listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        List<List<? extends Supplier>> tableSuppliers =  new ArrayList<ArrayList<Supplier>>();
 | 
				
			||||||
 | 
					       Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String table = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT  *  FROM supplier";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            while (rs.next()) {
 | 
				
			||||||
 | 
					                String sNumber = rs.getString(1) + " ";
 | 
				
			||||||
 | 
					                String sName = rs.getString(2) + " ";
 | 
				
			||||||
 | 
					                String bdate = rs.getDate(3) + " ";
 | 
				
			||||||
 | 
					                String status = rs.getInt(4) + " ";
 | 
				
			||||||
 | 
					                String city = rs.getString(5) + " ";
 | 
				
			||||||
 | 
					                table += sNumber + sName + bdate + status + city + "</br>";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null) {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (SQLException sqle) {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        result = table;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void viewSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String ret = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT snumber, sname, status, city, birthday  FROM supplier WHERE snumber=?";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            if (rs.next()) {
 | 
				
			||||||
 | 
					                this.snumber = rs.getString("snumber");
 | 
				
			||||||
 | 
					                ret += this.snumber + " ";
 | 
				
			||||||
 | 
					                this.sname = rs.getString("sname");
 | 
				
			||||||
 | 
					                ret += this.sname + " ";
 | 
				
			||||||
 | 
					                this.status = rs.getInt("status");
 | 
				
			||||||
 | 
					                ret += this.status + " ";
 | 
				
			||||||
 | 
					                this.city = rs.getString("city");
 | 
				
			||||||
 | 
					                ret += this.city + " ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Object bDate = rs.getObject("birthday");
 | 
				
			||||||
 | 
					                this.birthday = bDate.toString();
 | 
				
			||||||
 | 
					                ret += this.birthday;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                ret = this.snumber + " doesn't exist.";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                if (ps != null) {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (SQLException sqle) {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        this.result = ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,55 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Supplier {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private String snumber;
 | 
				
			||||||
 | 
					    private String sname;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSname(String sname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.sname = sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String birthday;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getBirthday()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBirthday(String birthday)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.birthday = birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSnumber()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSnumber(String snumber)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.snumber = snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String toString()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return "Supplier{" + "snumber=" + snumber + ", sname=" + sname + ", birthday=" + birthday + '}';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,380 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.bl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.ApplicationScoped;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author a. v. markou
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Named(value = "suppliers")
 | 
				
			||||||
 | 
					@ApplicationScoped
 | 
				
			||||||
 | 
					public class Suppliers implements Serializable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String snumber = "";
 | 
				
			||||||
 | 
					    String sname = "";
 | 
				
			||||||
 | 
					    int status = 0;
 | 
				
			||||||
 | 
					    String birthday = "";
 | 
				
			||||||
 | 
					    String city = "";
 | 
				
			||||||
 | 
					    String result = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public Suppliers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        connection();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSnumber()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSnumber(String snumber)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.snumber = snumber;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSname(String sname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.sname = sname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getStatus()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStatus(int status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.status = status;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getBirthday()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBirthday(String birthday)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.birthday = birthday;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getCity()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setCity(String city)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.city = city;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getConnectionResponse()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (con != null) {
 | 
				
			||||||
 | 
					            return "<p style=\"color:green\">Connection succesfull! <br />";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            connection();
 | 
				
			||||||
 | 
					            return "<p style=\"color:red\">Connection failed! <br />";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Connection connection() //throws InstantiationException, IllegalAccessException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /*
 | 
				
			||||||
 | 
					                String databaseName = "suppliers_parts_23";
 | 
				
			||||||
 | 
					                String userName = "admin";
 | 
				
			||||||
 | 
					                String password = "RangerDog01!";
 | 
				
			||||||
 | 
					                String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					                Connection con = null;
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					        } catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        System.out.println(url);
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void clear()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        status = 0;
 | 
				
			||||||
 | 
					        snumber = "";
 | 
				
			||||||
 | 
					        sname = "";
 | 
				
			||||||
 | 
					        birthday = "";
 | 
				
			||||||
 | 
					        city = "";
 | 
				
			||||||
 | 
					        result = "";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String table = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT  *  FROM supplier";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            int row = 0;
 | 
				
			||||||
 | 
					            while (rs.next()) {
 | 
				
			||||||
 | 
					                String sNumber = rs.getString(1) + " ";
 | 
				
			||||||
 | 
					                String sName = rs.getString(2) + " ";
 | 
				
			||||||
 | 
					                String bdate = rs.getDate(3) + " ";
 | 
				
			||||||
 | 
					                String status = rs.getInt(4) + " ";
 | 
				
			||||||
 | 
					                String city = rs.getString(5) + " ";
 | 
				
			||||||
 | 
					                table += sNumber + sName + bdate + status + city + "</br>";
 | 
				
			||||||
 | 
					                row++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null) {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (SQLException sqle) {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        result = table;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void viewSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        String ret = "";
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        ResultSet rs = null;
 | 
				
			||||||
 | 
					        String sqlStr = "SELECT snumber, sname, status, city, birthday  FROM supplier WHERE snumber=?";
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            if (rs.next()) {
 | 
				
			||||||
 | 
					                this.snumber = rs.getString("snumber");
 | 
				
			||||||
 | 
					                ret += this.snumber + " ";
 | 
				
			||||||
 | 
					                this.sname = rs.getString("sname");
 | 
				
			||||||
 | 
					                ret += this.sname + " ";
 | 
				
			||||||
 | 
					                this.status = rs.getInt("status");
 | 
				
			||||||
 | 
					                ret += this.status + " ";
 | 
				
			||||||
 | 
					                this.city = rs.getString("city");
 | 
				
			||||||
 | 
					                ret += this.city + " ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Object bDate = rs.getObject("birthday");
 | 
				
			||||||
 | 
					                this.birthday = bDate.toString();
 | 
				
			||||||
 | 
					                ret += this.birthday;
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                ret = this.snumber + " doesn't exist.";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                if (ps != null) {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (SQLException sqle) {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        this.result = ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void updateSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "UPDATE supplier SET snumber=?, sname=?, status=?, birthday=?, city=? WHERE snumber=?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            updateSupplier.setString(1, snumber);
 | 
				
			||||||
 | 
					            updateSupplier.setString(2, sname);
 | 
				
			||||||
 | 
					            updateSupplier.setInt(3, status);
 | 
				
			||||||
 | 
					            java.sql.Date bd = stringDateToSqlDate(this.birthday);
 | 
				
			||||||
 | 
					            updateSupplier.setDate(4, bd);
 | 
				
			||||||
 | 
					            updateSupplier.setString(5, city);
 | 
				
			||||||
 | 
					            updateSupplier.setString(6, snumber);
 | 
				
			||||||
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null) {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            } catch (SQLException sqlee) {
 | 
				
			||||||
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void deleteSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        int rowsAffected = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            String query = "DELETE FROM supplier WHERE snumber=? ";
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(query);
 | 
				
			||||||
 | 
					            ps.setString(1, snumber);
 | 
				
			||||||
 | 
					            rowsAffected = ps.executeUpdate();
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + rowsAffected;
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null) {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            } catch (SQLException sqlee) {
 | 
				
			||||||
 | 
					                sqlee.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void insertSupplier()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Connection con = connection();
 | 
				
			||||||
 | 
					        if (con == null) {
 | 
				
			||||||
 | 
					            result = "cannot connect to database";
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        PreparedStatement updateSupplier = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            updateSupplier = con.prepareStatement(
 | 
				
			||||||
 | 
					                    "INSERT INTO supplier (snumber, sname, status, birthday, city ) "
 | 
				
			||||||
 | 
					                    + "VALUES ( ?, ?, ? , ? ,? )");
 | 
				
			||||||
 | 
					            updateSupplier.setString(1, snumber);
 | 
				
			||||||
 | 
					            updateSupplier.setString(2, sname);
 | 
				
			||||||
 | 
					            updateSupplier.setInt(3, status);
 | 
				
			||||||
 | 
					            java.sql.Date sqlDate = stringDateToSqlDate(birthday);
 | 
				
			||||||
 | 
					            updateSupplier.setDate(4, sqlDate);
 | 
				
			||||||
 | 
					            updateSupplier.setString(5, city);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int updateCount = updateSupplier.executeUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            result = "number of rows affected: " + updateCount;
 | 
				
			||||||
 | 
					        } catch (Exception ex) {
 | 
				
			||||||
 | 
					            System.err.println(ex.toString());
 | 
				
			||||||
 | 
					            result = ex.toString();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                this.closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (updateSupplier != null) {
 | 
				
			||||||
 | 
					                    updateSupplier.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            } catch (SQLException e) {
 | 
				
			||||||
 | 
					                System.err.println(e.toString());
 | 
				
			||||||
 | 
					                result = e.toString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private java.sql.Date stringDateToSqlDate(String sDate)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        java.util.Date date = null;
 | 
				
			||||||
 | 
					        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            date = sdf.parse(sDate);
 | 
				
			||||||
 | 
					        } catch (ParseException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return new java.sql.Date(date.getTime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getResult()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return "<p style=\"color:green\">Suppliers <br />" + result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void closeDatabaseConnection(Connection con)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            if (con != null) {
 | 
				
			||||||
 | 
					                con.close();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            result = e.toString();
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.suppliers_parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.suppliers_parts.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee10")
 | 
				
			||||||
 | 
					public class JakartaEE10Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h:panelGrid columns="2">
 | 
				
			||||||
 | 
					                <h:outputLabel value="table name "/>
 | 
				
			||||||
 | 
					                <h:inputText value="#{queryBean.tableName}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="SELECT * FROM table" action="#{queryBean.queries()}"/>
 | 
				
			||||||
 | 
					                <h:outputText escape="false" style="color:green" value="#{queryBean.table}"> </h:outputText>  
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
 | 
				
			||||||
 | 
					    <context-param>
 | 
				
			||||||
 | 
					        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
 | 
				
			||||||
 | 
					        <param-value>Development</param-value>
 | 
				
			||||||
 | 
					    </context-param>
 | 
				
			||||||
 | 
					    <servlet>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
 | 
				
			||||||
 | 
					        <load-on-startup>1</load-on-startup>
 | 
				
			||||||
 | 
					    </servlet>
 | 
				
			||||||
 | 
					    <servlet-mapping>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <url-pattern>/faces/*</url-pattern>
 | 
				
			||||||
 | 
					    </servlet-mapping>
 | 
				
			||||||
 | 
					    <session-config>
 | 
				
			||||||
 | 
					        <session-timeout>
 | 
				
			||||||
 | 
					            30
 | 
				
			||||||
 | 
					        </session-timeout>
 | 
				
			||||||
 | 
					    </session-config>
 | 
				
			||||||
 | 
					    <welcome-file-list>
 | 
				
			||||||
 | 
					        <welcome-file>faces/index.xhtml</welcome-file>
 | 
				
			||||||
 | 
					    </welcome-file-list>
 | 
				
			||||||
 | 
					</web-app>
 | 
				
			||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="http://xmlns.jcp.org/jsf/html"
 | 
				
			||||||
 | 
					      xmlns:f="http://xmlns.jcp.org/jsf/core">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <h:outputStylesheet library="css" name="styles.css"/>
 | 
				
			||||||
 | 
					        <title>Supplier Parts DB</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h1>   Suppliers-Parts Database </h1>
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					            <h:panelGrid columns="2">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier ID:"/>
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.snumber}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="8">
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Supplier Name"/>
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.sname}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Status" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.status}"/>
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="Birthday" />
 | 
				
			||||||
 | 
					                <h:inputText value="#{suppliers.birthday}"/> 
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                <h:outputLabel styleClass="label" value="City" />
 | 
				
			||||||
 | 
					                <h:inputText 
 | 
				
			||||||
 | 
					                    value="#{suppliers.city}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid columns="6">
 | 
				
			||||||
 | 
					                <h:commandButton styleClass="button" value="View Supplier" action="#{suppliers.viewSupplier()}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Insert Supplier" action="#{suppliers.insertSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Update Supplier" action="#{suppliers.updateSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Delete Supplier" action="#{suppliers.deleteSupplier}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="List All Suppliers" action="#{suppliers.listAll}"/>
 | 
				
			||||||
 | 
					                <h:commandButton value="Clear" action="#{suppliers.clear}"/>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:panelGrid>
 | 
				
			||||||
 | 
					                <h:outputText escape="false" style="color:green" 
 | 
				
			||||||
 | 
					                              value="#{suppliers.result}">
 | 
				
			||||||
 | 
					                </h:outputText>
 | 
				
			||||||
 | 
					            </h:panelGrid>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					.body {
 | 
				
			||||||
 | 
					   background: #eee;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button {
 | 
				
			||||||
 | 
						margin: 10px;
 | 
				
			||||||
 | 
						border-left: thin solid darkGray;
 | 
				
			||||||
 | 
						border-bottom: thin solid darkGray;
 | 
				
			||||||
 | 
						border-top: thin solid lightGray;
 | 
				
			||||||
 | 
						border-right: thin solid lightGray;
 | 
				
			||||||
 | 
					        color: #777;
 | 
				
			||||||
 | 
					        background: #A7C942;
 | 
				
			||||||
 | 
					        font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					        border-radius: 20%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					h1 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   vertical-align: top;
 | 
				
			||||||
 | 
					   text-align: middle;
 | 
				
			||||||
 | 
					   font-style: italic;
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 2em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.label
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   color: #888;
 | 
				
			||||||
 | 
					   font-size: 0.8em;
 | 
				
			||||||
 | 
					   font-family: "Comic Sans MS";   
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					.leftImage {
 | 
				
			||||||
 | 
					   float: left;
 | 
				
			||||||
 | 
					   margin-right: 1em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.backLink {
 | 
				
			||||||
 | 
						font-style: italic;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tableHeader {
 | 
				
			||||||
 | 
					    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
 | 
				
			||||||
 | 
					    border-collapse:collapse;
 | 
				
			||||||
 | 
					    font-size:1.1em;
 | 
				
			||||||
 | 
					    text-align:left;
 | 
				
			||||||
 | 
					    padding-top:5px;
 | 
				
			||||||
 | 
					    padding-bottom:4px;
 | 
				
			||||||
 | 
					    background-color:#A7C942;
 | 
				
			||||||
 | 
					    color:white;
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.oddTableRow {
 | 
				
			||||||
 | 
					    border:1px solid #98bf21;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.evenTableRow {
 | 
				
			||||||
 | 
					    background-color: #eeeeee;
 | 
				
			||||||
 | 
					    font-size:1em;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    padding:3px 7px 2px 7px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    color:#000000;
 | 
				
			||||||
 | 
					    background-color:#EAF2D3;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.table {
 | 
				
			||||||
 | 
					    border:1px solid green;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="jakarta.faces.html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        Hello from Facelets
 | 
				
			||||||
 | 
					        <h:dataTable var="tableSupplier" value="#{supplierBean}">
 | 
				
			||||||
 | 
					            <f:facet name="snumber">
 | 
				
			||||||
 | 
					        </h:dataTable>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>edu.slcc.asdv.caleb</groupId>
 | 
				
			||||||
 | 
					    <artifactId>ProgrammingExam1Question3_CalebFontenot</artifactId>
 | 
				
			||||||
 | 
					    <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>ProgrammingExam1Question3_CalebFontenot-1.0-SNAPSHOT</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <jakartaee>10.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.8.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>11</source>
 | 
				
			||||||
 | 
					                    <target>11</target>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.3.2</version>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,58 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package bean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.annotation.ManagedBean;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.RequestScoped;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.SessionScoped;
 | 
				
			||||||
 | 
					import jakarta.faces.application.FacesMessage;
 | 
				
			||||||
 | 
					import jakarta.faces.context.FacesContext;
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Named(value="pageBean")
 | 
				
			||||||
 | 
					@RequestScoped
 | 
				
			||||||
 | 
					public class PageBean implements Serializable{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private String name;
 | 
				
			||||||
 | 
					    private int age;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return name;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public int getAge()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return age;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public void setName(String name)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.name = name;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public void setAge(int age)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.age = age;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void concatenate() {
 | 
				
			||||||
 | 
					        String output = name + ", " + age;
 | 
				
			||||||
 | 
					        System.out.println(output);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        FacesContext context = FacesContext.getCurrentInstance();
 | 
				
			||||||
 | 
					        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, output, null);
 | 
				
			||||||
 | 
					        context.addMessage(null, message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** Creates a new instance of PageBean */
 | 
				
			||||||
 | 
					    public PageBean() {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1question3_calebfontenot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1question3_calebfontenot.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee10")
 | 
				
			||||||
 | 
					public class JakartaEE10Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">
 | 
				
			||||||
 | 
					    <context-param>
 | 
				
			||||||
 | 
					        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
 | 
				
			||||||
 | 
					        <param-value>Development</param-value>
 | 
				
			||||||
 | 
					    </context-param>
 | 
				
			||||||
 | 
					    <servlet>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
 | 
				
			||||||
 | 
					        <load-on-startup>1</load-on-startup>
 | 
				
			||||||
 | 
					    </servlet>
 | 
				
			||||||
 | 
					    <servlet-mapping>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <url-pattern>/faces/*</url-pattern>
 | 
				
			||||||
 | 
					    </servlet-mapping>
 | 
				
			||||||
 | 
					    <session-config>
 | 
				
			||||||
 | 
					        <session-timeout>
 | 
				
			||||||
 | 
					            30
 | 
				
			||||||
 | 
					        </session-timeout>
 | 
				
			||||||
 | 
					    </session-config>
 | 
				
			||||||
 | 
					    <welcome-file-list>
 | 
				
			||||||
 | 
					        <welcome-file>faces/index.xhtml</welcome-file>
 | 
				
			||||||
 | 
					    </welcome-file-list>
 | 
				
			||||||
 | 
					</web-app>
 | 
				
			||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="jakarta.faces.html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					    <h:body>
 | 
				
			||||||
 | 
					        <h:form>
 | 
				
			||||||
 | 
					            <h1>Problem 3</h1>
 | 
				
			||||||
 | 
					            Name: <h:inputText value="#{pageBean.name}"/> <br/>
 | 
				
			||||||
 | 
					            Age: <h:inputText value="#{pageBean.age}"/> <br/>
 | 
				
			||||||
 | 
					            <h:commandButton value="Concatenate Name and Age" action="#{pageBean.concatenate()}"/>
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
							
								
								
									
										47
									
								
								Semester 2/Exams/ProgrammingExam1Question5/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Semester 2/Exams/ProgrammingExam1Question5/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>edu.slcc.asdv.caleb</groupId>
 | 
				
			||||||
 | 
					    <artifactId>ProgrammingExam1Question5</artifactId>
 | 
				
			||||||
 | 
					    <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>ProgrammingExam1Question5-1.0-SNAPSHOT</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <jakartaee>10.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>mysql</groupId>
 | 
				
			||||||
 | 
					            <artifactId>mysql-connector-java</artifactId>
 | 
				
			||||||
 | 
					            <version>8.0.33</version>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.8.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>11</source>
 | 
				
			||||||
 | 
					                    <target>11</target>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.3.2</version>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1question5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1question5.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee10")
 | 
				
			||||||
 | 
					public class JakartaEE10Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package pojo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DBConnection {
 | 
				
			||||||
 | 
					         public Connection connection( 
 | 
				
			||||||
 | 
					        String databaseName,
 | 
				
			||||||
 | 
					        String userName,
 | 
				
			||||||
 | 
					        String password,
 | 
				
			||||||
 | 
					        String URL2 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     ) //throws InstantiationException, IllegalAccessException
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Connection con;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {// Load Sun's jdbc driver
 | 
				
			||||||
 | 
					            Class.forName(URL2).newInstance();
 | 
				
			||||||
 | 
					            System.out.println("JDBC Driver loaded!");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e) // driver not found
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println("Unable to load database driver");
 | 
				
			||||||
 | 
					            System.err.println("Details : " + e);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        String ip = "localhost"; //internet connection
 | 
				
			||||||
 | 
					        String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false";
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            con = DriverManager.getConnection(url, userName, password);
 | 
				
			||||||
 | 
					            con.setReadOnly(false);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.err.println(e.toString());
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        System.out.println("connection successfull");
 | 
				
			||||||
 | 
					        return con;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					      public void closeDatabaseConnection( Connection con)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            if (con != null)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                con.close();
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        catch (SQLException e)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            System.out.println(e);
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package pojo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
 | 
					import java.sql.ParameterMetaData;
 | 
				
			||||||
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class DatabaseManipulation {
 | 
				
			||||||
 | 
					    public List<Travel> listAll()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        List<Travel> tavelTable = new ArrayList<Travel>();
 | 
				
			||||||
 | 
					        String databaseName = "travel";
 | 
				
			||||||
 | 
					        String userName = "java";
 | 
				
			||||||
 | 
					        String password = "]7tSXk.vIKpEjAb.";
 | 
				
			||||||
 | 
					        String URL2 = "com.mysql.jdbc.Driver";
 | 
				
			||||||
 | 
					        Connection con = new DBConnection().connection(
 | 
				
			||||||
 | 
					                databaseName, userName, password, URL2);
 | 
				
			||||||
 | 
					        PreparedStatement ps = null;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (con == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                throw new RuntimeException("cannot connect to database");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            String table = "";
 | 
				
			||||||
 | 
					            ResultSet rs = null;
 | 
				
			||||||
 | 
					            String sqlStr = "SELECT  *  FROM passenger";
 | 
				
			||||||
 | 
					            //prepare statement
 | 
				
			||||||
 | 
					            ps = con.prepareStatement(sqlStr);
 | 
				
			||||||
 | 
					            //execute
 | 
				
			||||||
 | 
					            rs = ps.executeQuery();
 | 
				
			||||||
 | 
					            int row = 0;
 | 
				
			||||||
 | 
					            while (rs.next())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int age = rs.getInt(1);
 | 
				
			||||||
 | 
					                int pid = rs.getInt(2);
 | 
				
			||||||
 | 
					                String pname = rs.getString(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Travel  travel = new Travel(age, pid, pname);
 | 
				
			||||||
 | 
					                tavelTable.add(travel);
 | 
				
			||||||
 | 
					                row++;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ex.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        finally
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                new DBConnection().closeDatabaseConnection(con);
 | 
				
			||||||
 | 
					                // close the resources 
 | 
				
			||||||
 | 
					                if (ps != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ps.close();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (SQLException sqle)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                sqle.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tavelTable;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,86 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package pojo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Travel {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int age;
 | 
				
			||||||
 | 
					    private int pid;
 | 
				
			||||||
 | 
					    private String pname;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the value of pname
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return the value of pname
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public String getPname()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return pname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Set the value of pname
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param pname new value of pname
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setPname(String pname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.pname = pname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the value of pid
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return the value of pid
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int getPid()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return pid;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Set the value of pid
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param pid new value of pid
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setPid(int pid)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.pid = pid;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Travel(int age, int pid, String pname)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.age = age;
 | 
				
			||||||
 | 
					        this.pid = pid;
 | 
				
			||||||
 | 
					        this.pname = pname;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the value of age
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return the value of age
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int getAge()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return age;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Set the value of age
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param age new value of age
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setAge(int age)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.age = age;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<web-app version="5.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">
 | 
				
			||||||
 | 
					    <context-param>
 | 
				
			||||||
 | 
					        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
 | 
				
			||||||
 | 
					        <param-value>Development</param-value>
 | 
				
			||||||
 | 
					    </context-param>
 | 
				
			||||||
 | 
					    <servlet>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
 | 
				
			||||||
 | 
					        <load-on-startup>1</load-on-startup>
 | 
				
			||||||
 | 
					    </servlet>
 | 
				
			||||||
 | 
					    <servlet-mapping>
 | 
				
			||||||
 | 
					        <servlet-name>Faces Servlet</servlet-name>
 | 
				
			||||||
 | 
					        <url-pattern>/faces/*</url-pattern>
 | 
				
			||||||
 | 
					    </servlet-mapping>
 | 
				
			||||||
 | 
					    <session-config>
 | 
				
			||||||
 | 
					        <session-timeout>
 | 
				
			||||||
 | 
					            30
 | 
				
			||||||
 | 
					        </session-timeout>
 | 
				
			||||||
 | 
					    </session-config>
 | 
				
			||||||
 | 
					    <welcome-file-list>
 | 
				
			||||||
 | 
					        <welcome-file>faces/index.xhtml</welcome-file>
 | 
				
			||||||
 | 
					    </welcome-file-list>
 | 
				
			||||||
 | 
					</web-app>
 | 
				
			||||||
@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8' ?>
 | 
				
			||||||
 | 
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
				
			||||||
 | 
					<html xmlns="http://www.w3.org/1999/xhtml"
 | 
				
			||||||
 | 
					      xmlns:h="jakarta.faces.html">
 | 
				
			||||||
 | 
					    <h:head>
 | 
				
			||||||
 | 
					        <title>Facelet Title</title>
 | 
				
			||||||
 | 
					    </h:head>
 | 
				
			||||||
 | 
					<h:form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <h:dataTable  var="travelTable"  
 | 
				
			||||||
 | 
					                          value="#{supplierBean.getTrav()}"  >
 | 
				
			||||||
 | 
					            <f:facet name="header"> <h:outputText value="Suppliers Table" style="font-size: 1.2em"/></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="snumber" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="true" value="#{supplier.snumber}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="sname" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.sname}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="birthday" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}" value="#{supplier.birthday}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="status" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.status}"/>
 | 
				
			||||||
 | 
					                </h:column>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="city" /></f:facet>                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <h:inputText disabled ="#{!supplier.modify}"  value="#{supplier.city}"/>
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <h:column> 
 | 
				
			||||||
 | 
					                    <f:facet name="header"> <h:outputText value="update" /></f:facet>                
 | 
				
			||||||
 | 
					                    <h:selectBooleanCheckbox  onclick="submit()"
 | 
				
			||||||
 | 
					                                              value="#{supplier.modify}">
 | 
				
			||||||
 | 
					                    </h:selectBooleanCheckbox >
 | 
				
			||||||
 | 
					                </h:column>  
 | 
				
			||||||
 | 
					            </h:dataTable>
 | 
				
			||||||
 | 
					            <h:commandButton value="Save" action="#{supplierBean.saveFromUpdate()}" />
 | 
				
			||||||
 | 
					        </h:form>
 | 
				
			||||||
 | 
					    </h:body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<project-shared-configuration>
 | 
				
			||||||
 | 
					    <!--
 | 
				
			||||||
 | 
					This file contains additional configuration written by modules in the NetBeans IDE.
 | 
				
			||||||
 | 
					The configuration is intended to be shared among all the users of project and
 | 
				
			||||||
 | 
					therefore it is assumed to be part of version control checkout.
 | 
				
			||||||
 | 
					Without this configuration present, some functionality in the IDE may be limited or fail altogether.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					Properties that influence various parts of the IDE, especially code formatting and the like. 
 | 
				
			||||||
 | 
					You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 | 
				
			||||||
 | 
					That way multiple projects can share the same settings (useful for formatting rules for example).
 | 
				
			||||||
 | 
					Any value defined here will override the pom.xml file value but is only applicable to the current project.
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
 | 
				
			||||||
 | 
					        <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
 | 
				
			||||||
 | 
					        <netbeans.hint.jdkPlatform>JDK_11__System_</netbeans.hint.jdkPlatform>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					</project-shared-configuration>
 | 
				
			||||||
@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<actions>
 | 
				
			||||||
 | 
					        <action>
 | 
				
			||||||
 | 
					            <actionName>run</actionName>
 | 
				
			||||||
 | 
					            <packagings>
 | 
				
			||||||
 | 
					                <packaging>war</packaging>
 | 
				
			||||||
 | 
					                <packaging>ear</packaging>
 | 
				
			||||||
 | 
					                <packaging>ejb</packaging>
 | 
				
			||||||
 | 
					            </packagings>
 | 
				
			||||||
 | 
					            <goals>
 | 
				
			||||||
 | 
					                <goal>package</goal>
 | 
				
			||||||
 | 
					            </goals>
 | 
				
			||||||
 | 
					            <properties>
 | 
				
			||||||
 | 
					                <netbeans.deploy>true</netbeans.deploy>
 | 
				
			||||||
 | 
					                <netbeans.deploy.clientUrlPart></netbeans.deploy.clientUrlPart>
 | 
				
			||||||
 | 
					            </properties>
 | 
				
			||||||
 | 
					        </action>
 | 
				
			||||||
 | 
					        <action>
 | 
				
			||||||
 | 
					            <actionName>debug</actionName>
 | 
				
			||||||
 | 
					            <packagings>
 | 
				
			||||||
 | 
					                <packaging>war</packaging>
 | 
				
			||||||
 | 
					                <packaging>ear</packaging>
 | 
				
			||||||
 | 
					                <packaging>ejb</packaging>
 | 
				
			||||||
 | 
					            </packagings>
 | 
				
			||||||
 | 
					            <goals>
 | 
				
			||||||
 | 
					                <goal>package</goal>
 | 
				
			||||||
 | 
					            </goals>
 | 
				
			||||||
 | 
					            <properties>
 | 
				
			||||||
 | 
					                <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>
 | 
				
			||||||
 | 
					                <netbeans.deploy>true</netbeans.deploy>
 | 
				
			||||||
 | 
					                <netbeans.deploy.clientUrlPart></netbeans.deploy.clientUrlPart>
 | 
				
			||||||
 | 
					            </properties>
 | 
				
			||||||
 | 
					        </action>
 | 
				
			||||||
 | 
					        <action>
 | 
				
			||||||
 | 
					            <actionName>profile</actionName>
 | 
				
			||||||
 | 
					            <packagings>
 | 
				
			||||||
 | 
					                <packaging>ejb</packaging>
 | 
				
			||||||
 | 
					                <packaging>ear</packaging>
 | 
				
			||||||
 | 
					                <packaging>war</packaging>
 | 
				
			||||||
 | 
					            </packagings>
 | 
				
			||||||
 | 
					            <goals>
 | 
				
			||||||
 | 
					                <goal>package</goal>
 | 
				
			||||||
 | 
					            </goals>
 | 
				
			||||||
 | 
					            <properties>
 | 
				
			||||||
 | 
					                <netbeans.deploy>true</netbeans.deploy>
 | 
				
			||||||
 | 
					                <netbeans.deploy.profilemode>true</netbeans.deploy.profilemode>
 | 
				
			||||||
 | 
					                <netbeans.deploy.clientUrlPart></netbeans.deploy.clientUrlPart>
 | 
				
			||||||
 | 
					            </properties>
 | 
				
			||||||
 | 
					        </action>
 | 
				
			||||||
 | 
					    </actions>
 | 
				
			||||||
							
								
								
									
										42
									
								
								Semester 2/Exams/ProgrammingExam1_CalebFontenot/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Semester 2/Exams/ProgrammingExam1_CalebFontenot/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
				
			||||||
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
 | 
					    <groupId>edu.slcc.asdv.caleb</groupId>
 | 
				
			||||||
 | 
					    <artifactId>ProgrammingExam1_CalebFontenot</artifactId>
 | 
				
			||||||
 | 
					    <version>1.0-SNAPSHOT</version>
 | 
				
			||||||
 | 
					    <packaging>war</packaging>
 | 
				
			||||||
 | 
					    <name>ProgrammingExam1_CalebFontenot-1.0-SNAPSHOT</name>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <properties>
 | 
				
			||||||
 | 
					        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
					        <jakartaee>10.0.0</jakartaee>
 | 
				
			||||||
 | 
					    </properties>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <dependencies>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>jakarta.platform</groupId>
 | 
				
			||||||
 | 
					            <artifactId>jakarta.jakartaee-api</artifactId>
 | 
				
			||||||
 | 
					            <version>${jakartaee}</version>
 | 
				
			||||||
 | 
					            <scope>provided</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <build>
 | 
				
			||||||
 | 
					        <plugins>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.8.1</version>
 | 
				
			||||||
 | 
					                <configuration>
 | 
				
			||||||
 | 
					                    <source>11</source>
 | 
				
			||||||
 | 
					                    <target>11</target>
 | 
				
			||||||
 | 
					                </configuration>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					            <plugin>
 | 
				
			||||||
 | 
					                <groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
					                <artifactId>maven-war-plugin</artifactId>
 | 
				
			||||||
 | 
					                <version>3.3.2</version>
 | 
				
			||||||
 | 
					            </plugin>
 | 
				
			||||||
 | 
					        </plugins>
 | 
				
			||||||
 | 
					    </build>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import exam.Class1;
 | 
				
			||||||
 | 
					import jakarta.inject.Named;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.RequestScoped;
 | 
				
			||||||
 | 
					import jakarta.enterprise.context.SessionScoped;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Named(value="myBean")
 | 
				
			||||||
 | 
					@RequestScoped
 | 
				
			||||||
 | 
					public class MyBean {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Class1 classObject = new Class1(1, "John");
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public Class1 getClassObject()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return classObject;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** Creates a new instance of MyBean */
 | 
				
			||||||
 | 
					    public MyBean() {
 | 
				
			||||||
 | 
					        System.out.println("MyBean constructor invoked");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void main(String[] args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        MyBean myBean = new MyBean();
 | 
				
			||||||
 | 
					        System.out.println(myBean.getClassObject());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1_calebfontenot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.ApplicationPath;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Configures Jakarta RESTful Web Services for the application.
 | 
				
			||||||
 | 
					 * @author Juneau
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@ApplicationPath("resources")
 | 
				
			||||||
 | 
					public class JakartaRestConfiguration extends Application {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					package edu.slcc.asdv.caleb.programmingexam1_calebfontenot.resources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.ws.rs.GET;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.Path;
 | 
				
			||||||
 | 
					import jakarta.ws.rs.core.Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Path("jakartaee10")
 | 
				
			||||||
 | 
					public class JakartaEE10Resource {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @GET
 | 
				
			||||||
 | 
					    public Response ping(){
 | 
				
			||||||
 | 
					        return Response
 | 
				
			||||||
 | 
					                .ok("ping Jakarta EE")
 | 
				
			||||||
 | 
					                .build();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package exam;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class Class1 implements Interface1 {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        private int x = 0;
 | 
				
			||||||
 | 
					        private String y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Class1(int x, String y)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.x = x;
 | 
				
			||||||
 | 
					        this.y = y;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getY()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return y;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public void setY(String y)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.y = y;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public int getX()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return x;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public void setX(int x)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        this.x = x;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int f1()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Random r = new Random();
 | 
				
			||||||
 | 
					        return r.nextInt(100);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			||||||
 | 
					 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package exam;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author caleb
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface Interface1 {
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					    @return a random integer in the range 0 to 100
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    int f1();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
 | 
				
			||||||
 | 
					    <!-- Define Persistence Unit -->
 | 
				
			||||||
 | 
					    <persistence-unit name="my_persistence_unit">
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    </persistence-unit>
 | 
				
			||||||
 | 
					</persistence>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
 | 
				
			||||||
 | 
					       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
				
			||||||
 | 
					       xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
 | 
				
			||||||
 | 
					       bean-discovery-mode="all">
 | 
				
			||||||
 | 
					</beans>
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
 | 
					    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    This program and the accompanying materials are made available under the
 | 
				
			||||||
 | 
					    terms of the Eclipse Public License v. 2.0, which is available at
 | 
				
			||||||
 | 
					    http://www.eclipse.org/legal/epl-2.0.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    This Source Code may also be made available under the following Secondary
 | 
				
			||||||
 | 
					    Licenses when the conditions for such availability set forth in the
 | 
				
			||||||
 | 
					    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 | 
				
			||||||
 | 
					    version 2 with the GNU Classpath Exception, which is available at
 | 
				
			||||||
 | 
					    https://www.gnu.org/software/classpath/license.html.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					<glassfish-web-app error-url="">
 | 
				
			||||||
 | 
					  <class-loader delegate="true"/>
 | 
				
			||||||
 | 
					  <jsp-config>
 | 
				
			||||||
 | 
					    <property name="keepgenerated" value="true">
 | 
				
			||||||
 | 
					      <description>Keep a copy of the generated servlet class' java code.</description>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </jsp-config>
 | 
				
			||||||
 | 
					</glassfish-web-app>
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user