@@ -0,0 +1,3438 @@
+package Entity;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A *%0A * @author peter%0A */%0A%0Apublic class AddPizza%0A%7B%0A    String dbURL = %22jdbc:derby://localhost:1527//home/peter/pizzabase%22;%0A    String tableName = %22pizza%22;%0A    // jdbc Connection%0A    Connection conn = null;%0A    Statement stmt = null;%0A    %0A    public AddPizza() %7B%0A    %7D%0A%0A    public String addPizza(String name, String desc, Double price) %7B%0A        String result = %22OK%22;%0A        %0A        try%0A        %7B%0A            Class.forName(%22org.apache.derby.jdbc.ClientDriver%22).newInstance();%0A            //Get a connection%0A            conn = DriverManager.getConnection(dbURL); %0A        %7D%0A        catch (ClassNotFoundException cnfe) %7B%0A            System.err.println(%22Derby driver not found.%22);%0A        %7D%0A        catch (InstantiationException %7C IllegalAccessException %7C SQLException except)%0A        %7B%0A            except.printStackTrace();%0A        %7D%0A%0A%0A        try%0A        %7B%0A            stmt = conn.createStatement();%0A            stmt.execute(%22insert into %22 + tableName + %22 values ('%22 + name + %22','%22 + desc + %22',%22 + price +%22)%22);%0A            stmt.close();%0A            %7D%0A            %0A            catch(SQLException sql)%0A            %7B%0A            //If the pizza name already exists:%0A                if (sql.getMessage().contains(%22duplicate key%22))%0A                %7B%0A                    result = %22DUPLICATE%22;%0A                %7D   %0A            %7D%0A%0A        %0A            try%0A            %7B%0A                if (stmt != null)%0A                %7B%0A                    stmt.close();%0A                %7D%0A                if (conn != null)%0A                %7B%0A                    DriverManager.getConnection(dbURL);%0A                    conn.close();%0A                %7D           %0A            %7D%0A            catch (SQLException sql)%0A            %7B%0A                sql.printStackTrace();%0A            %7D%0A            %0A        return result;%0A    %7D%0A    %0A    public void deletePizza(String name) %7B%0A        tableName = %22pizza%22;%0A        conn = getConnection(dbURL);%0A%0A        try%0A        %7B%0A            stmt = conn.createStatement();%0A            int executeUpdate = stmt.executeUpdate(%22delete from %22 + tableName + %22 where name = '%22 + name + %22'%22);%0A            stmt.close();%0A        %7D catch(SQLException sql) %7B%0A            sql.printStackTrace();%0A        %7D%0A        %0A        closeConnection(stmt, conn);%0A    %7D%0A        %0A    private Connection getConnection(String dbURL) %7B%0A    try%0A        %7B%0A            Class.forName(%22org.apache.derby.jdbc.ClientDriver%22).newInstance();%0A            //Get a connection%0A            conn = DriverManager.getConnection(dbURL); %0A        %7D%0A        catch (ClassNotFoundException cnfe) %7B%0A            System.err.println(%22Derby driver not found.%22);%0A        %7D%0A        catch (InstantiationException %7C IllegalAccessException %7C SQLException except)%0A        %7B%0A            except.printStackTrace();%0A        %7D%0A    return conn;%0A    %7D%0A    %0A    private void closeConnection(Statement stmt, Connection conn) %7B%0A    try%0A        %7B%0A            if (stmt != null)%0A            %7B%0A                stmt.close();%0A            %7D%0A            if (conn != null)%0A            %7B%0A                DriverManager.getConnection(dbURL);%0A                conn.close();%0A            %7D           %0A        %7D%0A        catch (SQLException sql)%0A        %7B%0A            sql.printStackTrace();%0A        %7D%0A    %7D%0A%0A%7D%0A

Create AddPizza.java