diff --git a/.gitignore b/.gitignore index 88d7799..45c20d7 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,10 @@ /Semester 2/Assignments/MP5-Binary-Files_CalebFontenot/build/ /Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/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/ diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/PartsBean.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/PartsBean.java new file mode 100644 index 0000000..abfef5d --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/PartsBean.java @@ -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 parts; + + public PartsBean() + { + parts = dms.listAll(); + } + + public List 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); + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/SupplierBean.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/SupplierBean.java index bb36e46..7b77efe 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/SupplierBean.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/beans/SupplierBean.java @@ -59,6 +59,14 @@ public class SupplierBean implements Serializable String msg = ("Numbers of rows updated: " + totalRowsUpdated); 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) { diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/DBase.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/DBase.java index 320a494..39217f9 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/DBase.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/DBase.java @@ -18,5 +18,7 @@ public interface DBase int update( T t) throws SQLException; + + int delete (T t) throws SQLException; } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java index dad35b6..6fa07d2 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java @@ -44,7 +44,7 @@ public class UtilitiesDatabase return null; } 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 { con = DriverManager.getConnection(url, userName, password); diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java index c01a329..b7fa193 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java @@ -24,8 +24,8 @@ public class DatabaseManipulationPart implements DBase { List tableParts = new ArrayList(); String databaseName = "suppliers_parts_23"; - String userName = "root"; - String password = "root"; + String userName = "java"; + String password = "1KUZ4r6.73IGu*18"; String URL2 = "com.mysql.jdbc.Driver"; Connection con = new UtilitiesDatabase().connection( databaseName, userName, password, URL2); @@ -38,7 +38,7 @@ public class DatabaseManipulationPart implements DBase } String table = ""; ResultSet rs = null; - String sqlStr = "SELECT * FROM part"; + String sqlStr = "SELECT * FROM part"; //prepare statement ps = con.prepareStatement(sqlStr); //execute @@ -84,8 +84,62 @@ public class DatabaseManipulationPart implements DBase System.out.println(dmp.listAll()); } - @Override + @Override 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 } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/Part.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/Part.java index 54bd19a..290ea85 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/Part.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/part/Part.java @@ -8,68 +8,65 @@ package edu.slcc.asdv.bl.part; * * @author asdv5 */ -public class Part -{ +public class Part { + private String pnumber; private String pname; private String color; 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.pname = pname; this.color = color; this.city = city; } - - public String getColor() - { + public String getColor() { return color; } - public void setColor(String color) - { + public void setColor(String color) { this.color = color; } - public String getCity() - { + public String getCity() { return city; } - public void setCity(String city) - { + public void setCity(String city) { this.city = city; } - public String getPname() - { + public String getPname() { return pname; } - public void setPname(String pname) - { + public void setPname(String pname) { this.pname = pname; } - public String getPnumber() - { + public String getPnumber() { return pnumber; } - public void setPnumber(String pnumber) - { + public void setPnumber(String pnumber) { this.pnumber = pnumber; } @Override - public String toString() - { + public String toString() { return "Part{" + "pnumber=" + pnumber + ", pname=" + pname + ", color=" + color + ", city=" + city + '}'; } - - - + } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java index ccadfb2..7d0bfcb 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java @@ -25,8 +25,8 @@ public class DatabaseManipulationSupplier implements DBase { List tableSuppliers = new ArrayList(); String databaseName = "suppliers_parts_23"; - String userName = "root"; - String password = "root"; + String userName = "java"; + String password = "1KUZ4r6.73IGu*18"; String URL2 = "com.mysql.jdbc.Driver"; Connection con = new UtilitiesDatabase().connection( databaseName, userName, password, URL2); @@ -85,8 +85,8 @@ public class DatabaseManipulationSupplier implements DBase throws SQLException { String databaseName = "suppliers_parts_23"; - String userName = "root"; - String password = "root"; + String userName = "java"; + String password = "1KUZ4r6.73IGu*18"; String URL2 = "com.mysql.jdbc.Driver"; Connection con = new UtilitiesDatabase().connection( databaseName, userName, password, URL2); @@ -137,4 +137,61 @@ public class DatabaseManipulationSupplier implements DBase } + 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; + } + } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DateValidator.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DateValidator.java new file mode 100644 index 0000000..cef2016 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/DateValidator.java @@ -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.")); + } + } +} + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/NumericValidator.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/NumericValidator.java new file mode 100644 index 0000000..b129c73 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/NumericValidator.java @@ -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.")); + } + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java index a0c664b..501856d 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java @@ -17,9 +17,19 @@ public class Supplier implements Serializable private String birthday; private int status; private String city; - + private boolean delete; private boolean modify; + public boolean isDelete() + { + return delete; + } + + public void setDelete(boolean delete) + { + this.delete = delete; + } + public boolean isModify() { return modify; @@ -39,6 +49,7 @@ public class Supplier implements Serializable this.status = status; this.city = city; this.modify = false; + this.delete = false; } public String getCity() diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/parts.xhtml b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/parts.xhtml new file mode 100644 index 0000000..6e327b7 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/parts.xhtml @@ -0,0 +1,59 @@ + + + + + Facelet Title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/supplier.xhtml b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/supplier.xhtml index 027a095..ef1c1b7 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/supplier.xhtml +++ b/Semester 2/Assignments/SuppliersPartsDatabase/src/main/webapp/supplier.xhtml @@ -19,29 +19,34 @@ + - + + + - + - + - + - + + + @@ -51,6 +56,9 @@ value="#{supplier.modify}"> + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DBase.java b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DBase.java index 3308858..655bea0 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DBase.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DBase.java @@ -12,9 +12,11 @@ import java.util.List; * * @author asdv5 */ -public interface DBase -{ - List listAll(); +public interface DBase { + + List listAll(); + + int update(T t) throws SQLException; - int update(T t) throws SQLException; - } + int delete(T t) throws SQLException; +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationParts.java b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationParts.java index 8c39ad3..e398ea3 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationParts.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationParts.java @@ -88,4 +88,10 @@ public class DatabaseManipulationParts implements DBase { 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 + } } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java index 3885dca..8902fc0 100644 --- a/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java +++ b/Semester 2/Assignments/SuppliersPartsDatabase_CalebFontenot/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java @@ -89,4 +89,10 @@ public class DatabaseManipulationSupplier implements DBase { 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 + } } diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/nb-configuration.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/nb-configuration.xml new file mode 100644 index 0000000..f29f292 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 9.0-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/pom.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/pom.xml new file mode 100644 index 0000000..2dbcc06 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + com.mycompany + SuppliersPartsDatabase + 1.0-SNAPSHOT + war + SuppliersPartsDatabase-1.0-SNAPSHOT + + + 1.8 + 1.8 + ${project.build.directory}/endorsed + UTF-8 + false + 9.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + com.mysql + mysql-connector-j + 8.1.0 + + + org.primefaces + primefaces + 12.0.0 + jakarta + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + jar + + + + + + + + + \ No newline at end of file diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/JakartaRestConfiguration.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/JakartaRestConfiguration.java new file mode 100644 index 0000000..110a745 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/resources/JakartaEE9Resource.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/resources/JakartaEE9Resource.java new file mode 100644 index 0000000..f7f850d --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/com/mycompany/supplierspartsdatabase/resources/JakartaEE9Resource.java @@ -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(); + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/beans/SupplierBean.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/beans/SupplierBean.java new file mode 100644 index 0000000..bb36e46 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/beans/SupplierBean.java @@ -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 suppliers; + + public SupplierBean() + { + suppliers = dms.listAll(); + } + + public List 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); + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/DBase.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/DBase.java new file mode 100644 index 0000000..320a494 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/DBase.java @@ -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 +{ + List listAll(); + + int update( T t) + throws SQLException; + +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java new file mode 100644 index 0000000..dad35b6 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/UtilitiesDatabase.java @@ -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() ); + + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java new file mode 100644 index 0000000..c01a329 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/DatabaseManipulationPart.java @@ -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 +{ + @Override + public List listAll() + { + List tableParts = new ArrayList(); + 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 + } +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/Part.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/Part.java new file mode 100644 index 0000000..54bd19a --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/part/Part.java @@ -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 + '}'; + } + + + +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java new file mode 100644 index 0000000..ccadfb2 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/DatabaseManipulationSupplier.java @@ -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 +{ + @Override + public List listAll() + { + List tableSuppliers = new ArrayList(); + 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; + } + + +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java new file mode 100644 index 0000000..a0c664b --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/java/edu/slcc/asdv/bl/supplier/Supplier.java @@ -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 + '}'; + } + + + +} diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/resources/META-INF/persistence.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..baad290 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..b3a1279 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..584a477 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/web.xml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..11562f0 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/supplier.xhtml + + diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/index.xhtml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/index.xhtml new file mode 100644 index 0000000..3220605 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/index.xhtml @@ -0,0 +1,51 @@ + + + + + + Supplier Parts DB + + + + +

Suppliers-Parts Database

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ \ No newline at end of file diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/resources/css/styles.css b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/resources/css/styles.css new file mode 100644 index 0000000..9d96af6 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/resources/css/styles.css @@ -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; +} \ No newline at end of file diff --git a/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/supplier.xhtml b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/supplier.xhtml new file mode 100644 index 0000000..027a095 --- /dev/null +++ b/Semester 2/Assignments/SuppliersPartsDatabase_old/src/main/webapp/supplier.xhtml @@ -0,0 +1,58 @@ + + + + + Facelet Title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/nb-configuration.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/nb-configuration.xml new file mode 100644 index 0000000..5e1a2de --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/nb-configuration.xml @@ -0,0 +1,20 @@ + + + + + + 10-web + gfv700ee10 + Facelets + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/pom.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/pom.xml new file mode 100644 index 0000000..f685e1d --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/pom.xml @@ -0,0 +1,77 @@ + + 4.0.0 + edu.slcc.asdv + suppliers_parts + 1 + war + suppliers_parts-1 + + + 11 + 11 + ${project.build.directory}/endorsed + UTF-8 + false + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + jar + + + + + + + + + \ No newline at end of file diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java new file mode 100644 index 0000000..53b781c --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java @@ -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 "

Connection succesfull!
"; + } + else + { + connection(); + return "

Connection failed!
"; + } + + } + 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 + "
"; + } + } + 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 "

Suppliers
" + result; + + } + + + + public void closeDatabaseConnection( Connection con) + { + try + { + if (con != null) + { + con.close(); + } + } + catch (SQLException e) + { + result = e.toString(); + e.printStackTrace(); + } + } +} diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java new file mode 100644 index 0000000..d9a2934 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..104ce24 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/resources/META-INF/persistence.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/SelectAllFromTable.xhtml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/SelectAllFromTable.xhtml new file mode 100644 index 0000000..517c356 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/SelectAllFromTable.xhtml @@ -0,0 +1,21 @@ + + + + + Facelet Title + + + + + + + + + + + + + + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/web.xml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/index.xhtml b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/index.xhtml new file mode 100644 index 0000000..4b4a219 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/index.xhtml @@ -0,0 +1,52 @@ + + + + + + Supplier Parts DB + + + + +

Suppliers-Parts Database

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/resources/css/styles.css b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/resources/css/styles.css new file mode 100644 index 0000000..9d96af6 --- /dev/null +++ b/Semester 2/Assignments/SwingTest/suppliers_parts/src/main/webapp/resources/css/styles.css @@ -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; +} \ No newline at end of file diff --git a/Semester 2/Assignments/suppliers_parts/nb-configuration.xml b/Semester 2/Assignments/suppliers_parts/nb-configuration.xml index aeaf7bc..5e1a2de 100644 --- a/Semester 2/Assignments/suppliers_parts/nb-configuration.xml +++ b/Semester 2/Assignments/suppliers_parts/nb-configuration.xml @@ -16,12 +16,5 @@ Any value defined here will override the pom.xml file value but is only applicab 10-web gfv700ee10 Facelets - JDK_11__System_ - /less:/css - false - false - - - /scss:/css diff --git a/Semester 2/Assignments/suppliers_parts/pom.xml b/Semester 2/Assignments/suppliers_parts/pom.xml index 1c7e8f4..f685e1d 100644 --- a/Semester 2/Assignments/suppliers_parts/pom.xml +++ b/Semester 2/Assignments/suppliers_parts/pom.xml @@ -23,11 +23,6 @@ ${jakartaee} provided - - mysql - mysql-connector-java - 8.0.33 - diff --git a/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/DBase.java b/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/DBase.java index da7a965..e2aad3d 100644 --- a/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/DBase.java +++ b/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/DBase.java @@ -4,6 +4,7 @@ */ package edu.slcc.asdv.bl; +import java.sql.SQLException; import java.util.List; /** @@ -12,4 +13,7 @@ import java.util.List; */ public interface DBase { List> listAll(); + + int delete( T t) + throws SQLException; } diff --git a/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java b/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java index 8f402bc..c4c2155 100644 --- a/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java +++ b/Semester 2/Assignments/suppliers_parts/src/main/java/edu/slcc/asdv/bl/Suppliers.java @@ -8,7 +8,6 @@ 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; @@ -18,17 +17,17 @@ import jakarta.inject.Named; */ @Named(value = "suppliers") @ApplicationScoped -public class Suppliers implements Serializable { +public class Suppliers implements Serializable +{ String snumber = ""; String sname = ""; int status = 0; String birthday = ""; String city = ""; + String result = ""; - - public Suppliers() { connection(); @@ -87,53 +86,91 @@ public class Suppliers implements Serializable { public String getConnectionResponse() { Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; + if (con == null) + { + result = "cannot connect to database" ; return null; - } - if (con != null) { + } + if (con != null) + { return "

Connection succesfull!
"; - } else { + } + else + { connection(); return "

Connection failed!
"; - } + } } + 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"; - Connection con = null; - */ + 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 + } + 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); + String url = "jdbc:mysql://" + ip + ":8889/" + databaseName + "?useSSL=false"; + try { con = DriverManager.getConnection(url, userName, password); con.setReadOnly(false); - } catch (Exception e) { + } + 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; @@ -147,63 +184,72 @@ public class Suppliers implements Serializable { public void listAll() { Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; - return; - } + if (con == null) + { + result = "cannot connect to database" ; + return ; + } String table = ""; PreparedStatement ps = null; ResultSet rs = null; String sqlStr = "SELECT * FROM supplier"; - try { + try + { //prepare statement ps = con.prepareStatement(sqlStr); //execute rs = ps.executeQuery(); - int row = 0; - while (rs.next()) { + while (rs.next()) + { String sNumber = rs.getString(1) + " "; String sName = rs.getString(2) + " "; - String bdate = rs.getDate(3) + " "; String status = rs.getInt(4) + " "; + String bdate = rs.getDate(3) + " "; String city = rs.getString(5) + " "; table += sNumber + sName + bdate + status + city + "
"; - row++; - } - } catch (Exception ex) { + } + } + catch (Exception ex) + { ex.printStackTrace(); - } finally { - try { - closeDatabaseConnection(con); + } + finally + { + try + { + closeDatabaseConnection( con); // close the resources - if (ps != null) { + if (ps != null) + { ps.close(); - } - } catch (SQLException sqle) { - sqle.printStackTrace(); - } - } + } + } + catch (SQLException sqle){ sqle.printStackTrace(); } + } result = table; } public void viewSupplier() { Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; - return; - } + 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 { + 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()) { + if (rs.next()) + { this.snumber = rs.getString("snumber"); ret += this.snumber + " "; this.sname = rs.getString("sname"); @@ -212,110 +258,133 @@ public class Suppliers implements Serializable { 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.birthday; + } + else ret = this.snumber + " doesn't exist."; - } - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - try { + } + catch (Exception ex){ex.printStackTrace();} + finally + { + try + { this.closeDatabaseConnection(con); - if (ps != null) { + if (ps != null) ps.close(); - } - } catch (SQLException sqle) { - sqle.printStackTrace(); - } - } + } + catch (SQLException sqle){ sqle.printStackTrace();} + } this.result = ret; } public void updateSupplier() { Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; - return; - } + if (con == null) + { + result = "cannot connect to database" ; + return ; + } PreparedStatement updateSupplier = null; - try { + 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); + 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) { + } + catch (Exception ex) + { System.err.println(ex.toString()); - } finally { - try { + } + finally + { + try + { this.closeDatabaseConnection(con); // close the resources - if (updateSupplier != null) { + if (updateSupplier != null) + { updateSupplier.close(); - } + } - } catch (SQLException sqlee) { + } + catch (SQLException sqlee) + { sqlee.printStackTrace(); - } - } + } + } } public void deleteSupplier() { - + Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; - return; - } + if (con == null) + { + result = "cannot connect to database" ; + return ; + } PreparedStatement ps = null; int rowsAffected = -1; - try { + 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) { + } + catch (Exception ex) + { System.err.println(ex.toString()); - } finally { - try { + } + finally + { + try + { this.closeDatabaseConnection(con); // close the resources - if (ps != null) { + if (ps != null) + { ps.close(); - } + } - } catch (SQLException sqlee) { + } + catch (SQLException sqlee) + { sqlee.printStackTrace(); - } - } + } + } } public void insertSupplier() { - Connection con = connection(); - if (con == null) { - result = "cannot connect to database"; - return; - } + Connection con = connection(); + if (con == null) + { + result = "cannot connect to database" ; + return ; + } PreparedStatement updateSupplier = null; - try { + try + { updateSupplier = con.prepareStatement( "INSERT INTO supplier (snumber, sname, status, birthday, city ) " + "VALUES ( ?, ?, ? , ? ,? )"); @@ -329,35 +398,45 @@ public class Suppliers implements Serializable { int updateCount = updateSupplier.executeUpdate(); result = "number of rows affected: " + updateCount; - } catch (Exception ex) { + } + catch (Exception ex) + { System.err.println(ex.toString()); result = ex.toString(); - } finally { - try { + } + finally + { + try + { this.closeDatabaseConnection(con); // close the resources - if (updateSupplier != null) { + if (updateSupplier != null) + { updateSupplier.close(); - } + } - } catch (SQLException e) { + } + catch (SQLException e) + { System.err.println(e.toString()); result = e.toString(); - } - } + } + } } - - private java.sql.Date stringDateToSqlDate(String sDate) +private java.sql.Date stringDateToSqlDate(String sDate) { java.util.Date date = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - try { + try + { date = sdf.parse(sDate); - } catch (ParseException e) { + } + catch (ParseException e) + { e.printStackTrace(); - } - return new java.sql.Date(date.getTime()); - + } + return new java.sql.Date( date.getTime() ); + } public String getResult() @@ -366,15 +445,21 @@ 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(); - } - } catch (SQLException e) { + } + } + catch (SQLException e) + { result = e.toString(); e.printStackTrace(); - } + } } } diff --git a/Semester 2/Assignments/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Assignments/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml index 584a477..673cc06 100644 --- a/Semester 2/Assignments/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml +++ b/Semester 2/Assignments/suppliers_parts/src/main/webapp/WEB-INF/glassfish-web.xml @@ -1,5 +1,4 @@ - + diff --git a/Semester 2/Assignments/suppliers_parts_old/nb-configuration.xml b/Semester 2/Assignments/suppliers_parts_old/nb-configuration.xml new file mode 100644 index 0000000..aeaf7bc --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/nb-configuration.xml @@ -0,0 +1,27 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + /less:/css + false + false + + + /scss:/css + + diff --git a/Semester 2/Assignments/suppliers_parts_old/pom.xml b/Semester 2/Assignments/suppliers_parts_old/pom.xml new file mode 100644 index 0000000..1c7e8f4 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + edu.slcc.asdv + suppliers_parts + 1 + war + suppliers_parts-1 + + + 11 + 11 + ${project.build.directory}/endorsed + UTF-8 + false + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + mysql + mysql-connector-java + 8.0.33 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + jar + + + + + + + + + \ No newline at end of file diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DBase.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DBase.java new file mode 100644 index 0000000..da7a965 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DBase.java @@ -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 { + List> listAll(); +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java new file mode 100644 index 0000000..1749d63 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/DatabaseManipulationSupplier.java @@ -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 { + + @Override + public List> listAll() + { + List> tableSuppliers = new ArrayList>(); + 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 + "
"; + } + } 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; + } +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Supplier.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Supplier.java new file mode 100644 index 0000000..f75ea89 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Supplier.java @@ -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 + '}'; + } + +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Suppliers.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Suppliers.java new file mode 100644 index 0000000..8f402bc --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/bl/Suppliers.java @@ -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 "

Connection succesfull!
"; + } else { + connection(); + return "

Connection failed!
"; + } + + } + + 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 + "
"; + 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 "

Suppliers
" + result; + + } + + public void closeDatabaseConnection(Connection con) + { + try { + if (con != null) { + con.close(); + } + } catch (SQLException e) { + result = e.toString(); + e.printStackTrace(); + } + } +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java new file mode 100644 index 0000000..d9a2934 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..104ce24 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/java/edu/slcc/asdv/suppliers_parts/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/resources/META-INF/persistence.xml b/Semester 2/Assignments/suppliers_parts_old/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/SelectAllFromTable.xhtml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/SelectAllFromTable.xhtml new file mode 100644 index 0000000..517c356 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/SelectAllFromTable.xhtml @@ -0,0 +1,21 @@ + + + + + Facelet Title + + + + + + + + + + + + + + + diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..584a477 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/web.xml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/index.xhtml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/index.xhtml new file mode 100644 index 0000000..4b4a219 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/index.xhtml @@ -0,0 +1,52 @@ + + + + + + Supplier Parts DB + + + + +

Suppliers-Parts Database

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/resources/css/styles.css b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/resources/css/styles.css new file mode 100644 index 0000000..9d96af6 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/resources/css/styles.css @@ -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; +} \ No newline at end of file diff --git a/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/supplier.xhtml b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/supplier.xhtml new file mode 100644 index 0000000..30ace59 --- /dev/null +++ b/Semester 2/Assignments/suppliers_parts_old/src/main/webapp/supplier.xhtml @@ -0,0 +1,14 @@ + + + + + Facelet Title + + + Hello from Facelets + + + + + diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/nb-configuration.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/nb-configuration.xml new file mode 100644 index 0000000..f89ff8d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/pom.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/pom.xml new file mode 100644 index 0000000..934af21 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + edu.slcc.asdv.caleb + ProgrammingExam1Question3_CalebFontenot + 1.0-SNAPSHOT + war + ProgrammingExam1Question3_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/bean/PageBean.java b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/bean/PageBean.java new file mode 100644 index 0000000..8ca6c37 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/bean/PageBean.java @@ -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() { + } + +} diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..acdadc1 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..0519262 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/resources/META-INF/persistence.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/web.xml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f182148 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/index.xhtml b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/index.xhtml new file mode 100644 index 0000000..bf04d54 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question3_CalebFontenot/src/main/webapp/index.xhtml @@ -0,0 +1,16 @@ + + + + + Facelet Title + + + +

Problem 3

+ Name:
+ Age:
+ +
+
+ diff --git a/Semester 2/Exams/ProgrammingExam1Question5/nb-configuration.xml b/Semester 2/Exams/ProgrammingExam1Question5/nb-configuration.xml new file mode 100644 index 0000000..f89ff8d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Exams/ProgrammingExam1Question5/pom.xml b/Semester 2/Exams/ProgrammingExam1Question5/pom.xml new file mode 100644 index 0000000..7db0cbd --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + edu.slcc.asdv.caleb + ProgrammingExam1Question5 + 1.0-SNAPSHOT + war + ProgrammingExam1Question5-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + mysql + mysql-connector-java + 8.0.33 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/JakartaRestConfiguration.java b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/JakartaRestConfiguration.java new file mode 100644 index 0000000..c336efa --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/resources/JakartaEE10Resource.java b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..085a5a0 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/edu/slcc/asdv/caleb/programmingexam1question5/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DBConnection.java b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DBConnection.java new file mode 100644 index 0000000..b3536ea --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DBConnection.java @@ -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(); + } + } + +} diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DatabaseManipulation.java b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DatabaseManipulation.java new file mode 100644 index 0000000..4041a2d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/DatabaseManipulation.java @@ -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 listAll() + { + List tavelTable = new ArrayList(); + 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; + } + +} + diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/Travel.java b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/Travel.java new file mode 100644 index 0000000..55bdc63 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/java/pojo/Travel.java @@ -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; + } + +} diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/resources/META-INF/persistence.xml b/Semester 2/Exams/ProgrammingExam1Question5/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/web.xml b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f182148 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/index.xhtml b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/index.xhtml new file mode 100644 index 0000000..799ff09 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1Question5/src/main/webapp/index.xhtml @@ -0,0 +1,54 @@ + + + + + Facelet Title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nb-configuration.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nb-configuration.xml new file mode 100644 index 0000000..f89ff8d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nbactions.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nbactions.xml new file mode 100644 index 0000000..e06eb86 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/nbactions.xml @@ -0,0 +1,50 @@ + + + + run + + war + ear + ejb + + + package + + + true + + + + + debug + + war + ear + ejb + + + package + + + true + true + + + + + profile + + ejb + ear + war + + + package + + + true + true + + + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/pom.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/pom.xml new file mode 100644 index 0000000..68979dd --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + edu.slcc.asdv.caleb + ProgrammingExam1_CalebFontenot + 1.0-SNAPSHOT + war + ProgrammingExam1_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/beans/MyBean.java b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/beans/MyBean.java new file mode 100644 index 0000000..56f8963 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/beans/MyBean.java @@ -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()); + } +} diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/JakartaRestConfiguration.java b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..dc8e79d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/resources/JakartaEE10Resource.java b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..f989551 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexam1_calebfontenot/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Class1.java b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Class1.java new file mode 100644 index 0000000..8646d62 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Class1.java @@ -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); + } + +} diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Interface1.java b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Interface1.java new file mode 100644 index 0000000..8677584 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/java/exam/Interface1.java @@ -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(); +} diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/resources/META-INF/persistence.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..584a477 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f182148 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web_1.xml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web_1.xml new file mode 100644 index 0000000..4d40961 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/WEB-INF/web_1.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/index.xhtml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/index.xhtml new file mode 100644 index 0000000..510f6ef --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/index.xhtml @@ -0,0 +1,15 @@ + + + + + Facelet Title + + + + This is x of Class1:
+ This is y of Class1:
+ This is method f1 of Class1: +
+
+ \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/newjsf.xhtml b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/newjsf.xhtml new file mode 100644 index 0000000..ea3a26b --- /dev/null +++ b/Semester 2/Exams/ProgrammingExam1_CalebFontenot/src/main/webapp/newjsf.xhtml @@ -0,0 +1,11 @@ + + + + + Facelet Title + + + Hello from Facelets + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/faces-config.NavData b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/faces-config.NavData new file mode 100644 index 0000000..298bfc5 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/faces-config.NavData @@ -0,0 +1,6 @@ + + + + + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/nb-configuration.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/nb-configuration.xml new file mode 100644 index 0000000..f89ff8d --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/pom.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/pom.xml new file mode 100644 index 0000000..bc86c75 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + edu.slcc.asdv.caleb + ProgrammingExamQuestion2_CalebFontenot + 1.0-SNAPSHOT + war + ProgrammingExamQuestion2_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/JakartaRestConfiguration.java b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..c6fe699 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.caleb.programmingexamquestion2_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 { + +} diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/resources/JakartaEE10Resource.java b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..01a54b2 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/programmingexamquestion2_calebfontenot/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.caleb.programmingexamquestion2_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(); + } +} diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/resources/META-INF/persistence.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/classes/message.properties b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/classes/message.properties new file mode 100644 index 0000000..eb86ef3 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/classes/message.properties @@ -0,0 +1,2 @@ +message1=This title is from the properties file. +message2=This button value is from the properties file and its class-style from css \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/faces-config.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 0000000..dcd2a26 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,36 @@ + + + + + + en + + + message + msgs + + + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/web.xml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f182148 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/index.xhtml b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/index.xhtml new file mode 100644 index 0000000..9fa7607 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/index.xhtml @@ -0,0 +1,12 @@ + + + + + + #{msgs.message1} + + + + + diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/css/style.css b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/css/style.css new file mode 100644 index 0000000..8b88a5f --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/css/style.css @@ -0,0 +1,18 @@ +/* +Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license +Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/CascadeStyleSheet.css to edit this template +*/ +/* + Created on : Nov 1, 2023, 11:21:04 AM + Author : caleb +*/ +.buttonStyle { + font-family: Arial, Helvetica, sans-serif; + font-size: 30px; + color:white; + background: blue; + border-radius: 12%; +} +.background { + background-color: yellow; +} \ No newline at end of file diff --git a/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/message.properties b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/message.properties new file mode 100644 index 0000000..ca30fa0 --- /dev/null +++ b/Semester 2/Exams/ProgrammingExamQuestion2_CalebFontenot/src/main/webapp/resources/message.properties @@ -0,0 +1,2 @@ +message1="This title is from the properties file." +message2="This button value is from the properties file and its class-style from css" \ No newline at end of file diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/nb-configuration.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/nb-configuration.xml new file mode 100644 index 0000000..f89ff8d --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_11__System_ + + diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/pom.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/pom.xml new file mode 100644 index 0000000..b77d48f --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + edu.slcc.asdv.caleb + ProgrammingExam1Question4_CalebFontenot + 1.0-SNAPSHOT + war + ProgrammingExam1Question4_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/bean/PageBean.java b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/bean/PageBean.java new file mode 100644 index 0000000..2389daa --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/bean/PageBean.java @@ -0,0 +1,73 @@ +/* + * 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") +@SessionScoped +public class PageBean implements Serializable{ + + private String name; + private int age; + private String bestFriend = "nobody :("; + + public String getBestFriend() + { + return bestFriend; + } + + public void setBestFriend(String bestFriend) + { + this.bestFriend = bestFriend; + } + + + 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); + } + + public void changeBestFriendName(String name) { + bestFriend = name; + } + + /** Creates a new instance of PageBean */ + public PageBean() { + } + +} diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..acdadc1 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/JakartaRestConfiguration.java @@ -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 { + +} diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..0519262 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/java/edu/slcc/asdv/caleb/programmingexam1question3_calebfontenot/resources/JakartaEE10Resource.java @@ -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(); + } +} diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/resources/META-INF/persistence.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/beans.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/web.xml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..f182148 --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/index.xhtml b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/index.xhtml new file mode 100644 index 0000000..981008e --- /dev/null +++ b/Semester 2/Exams/edu.slcc.asdv.caleb_ProgrammingExam1Question4_CalebFontenot_war_1.0-SNAPSHOT/src/main/webapp/index.xhtml @@ -0,0 +1,19 @@ + + + + + Facelet Title + + + +

Problem 3

+ Name:
+ Age:
+ + +
+ +
+
+ diff --git a/Semester 2/WEB_DEV_MIDTERM_STUDY_GUIDE_FILLED_OUT.pdf b/Semester 2/WEB_DEV_MIDTERM_STUDY_GUIDE_FILLED_OUT.pdf new file mode 100644 index 0000000..a5e446e Binary files /dev/null and b/Semester 2/WEB_DEV_MIDTERM_STUDY_GUIDE_FILLED_OUT.pdf differ diff --git a/Semester 2/ZIPs/ProgrammingExam1Question3_CalebFontenot.zip b/Semester 2/ZIPs/ProgrammingExam1Question3_CalebFontenot.zip new file mode 100644 index 0000000..3284de7 Binary files /dev/null and b/Semester 2/ZIPs/ProgrammingExam1Question3_CalebFontenot.zip differ diff --git a/Semester 2/ZIPs/ProgrammingExam1Question4_CalebFontenot.zip b/Semester 2/ZIPs/ProgrammingExam1Question4_CalebFontenot.zip new file mode 100644 index 0000000..5b6ce5b Binary files /dev/null and b/Semester 2/ZIPs/ProgrammingExam1Question4_CalebFontenot.zip differ diff --git a/Semester 2/ZIPs/ProgrammingExamQuestion1_CalebFontenot.zip b/Semester 2/ZIPs/ProgrammingExamQuestion1_CalebFontenot.zip new file mode 100644 index 0000000..3f159af Binary files /dev/null and b/Semester 2/ZIPs/ProgrammingExamQuestion1_CalebFontenot.zip differ diff --git a/Semester 2/ZIPs/ProgrammingExamQuestion2_CalebFontenot.zip b/Semester 2/ZIPs/ProgrammingExamQuestion2_CalebFontenot.zip new file mode 100644 index 0000000..c36cc1a Binary files /dev/null and b/Semester 2/ZIPs/ProgrammingExamQuestion2_CalebFontenot.zip differ