Java Collection Framework #Java Short Notes

Array
Benefits Constraints
  • Data access is fast.
  • Good for ordered data, which is not changed or searched frequently.
  • Inefficient if number of elements grow.
  • Inefficient if an element to be inserted in middle of collection.
  • Provides no special search mechanism.
Linked List
Benefits Constraints
  • Allows efficient inserts/delete at any location
  • Allows arbitrary growth of collection.
  • Applying order to the elements is easy.
  • Slower while accessing elements by index.
  • No special search mechanism is provided.

Tree
Benefits Constraints
  • Easy addition/deletion in middle.
  • Allows arbitrary growth.
  • A better and efficient search mechanism.
  • Ordering is peculiar and some comparison mechanism is required.
  • Searching is not efficient for unevenly distributed data.

Hashtable
Benefits Constraints
  • Efficient searching.
  • Good access mechanism.
  • Allows arbitrary growth of collection.
  • Not good for small data set because of overheads.
  • Overhead for storing keys for the values in collection.
  • Overhead of hashing scheme.

From: http://sitestree.com/?p=4861
Categories:Java Short Notes
Tags:
Post Data:2007-06-09 22:01:31

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

JDBC: Stored Procedure #Java Short Notes

Sample stored procedure call using JDBC:Call stored procedure to change/set a value in the database

//set birthday - supply professor nametry{ String professor= "dylan thomas"; CallableStatement proc = connection.prepareCall("{ call set_birth_date(?, ?) }"); proc.setString(1, professor); proc.setString(2, '1950-01-01'); cs.execute();}catch (SQLException e){ // ....}Stored procedures can also return result/data to the caller: like//return birth dayconnection.setAutoCommit(false);CallableStatement proc = connection.prepareCall("{ ? = call birthday_when(?) }");proc.registerOutParameter(1, Types.Timestamp);proc.setString(2, professorName);cs.execute();Timestamp age = proc.getString(2);Stored procedures can also return complex data like resultsets. JDBC drivers from oracle, Sql Server, PostgreSQL support this.

From: http://sitestree.com/?p=4839
Categories:Java Short Notes
Tags:
Post Data:2010-07-30 07:32:42

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Comparison EJB 2 and EJB 3 #Java Short Notes

Comparison EJB 2 and EJB 3

  1. EJB 2.0 has deployment descriptors but EJB 3.0 has no deployment descriptor
  2. In EJB 2.0 you have to write Home and Remote Interfaces But in EJB3.0 you do not need to write Home interfaces
  3. In EJB 3.0, all entities are identified with ‘@’
  4. In EJB 3.0 methods like ejbPassivate, ejbActivate, ejbLoad, ejbStore, etc. are not required
  5. EJB 3.0 is totally newly designed including the entity manager
  6. EJB 3.0 entity beans are just POJO
  7. No EJB container required to run
  8. EJB 3.0 supports Java Persistence API for all of its data needs
  9. No XMLDeployment Descriptors but annotations
  10. EJB 3.0 entity beans/JPA becomes local
  11. Queries are very flexible. Multiple levels of joins are enabled
  12. EJB 3.0 pluggable, security enabled

From: http://sitestree.com/?p=4835
Categories:Java Short Notes
Tags:
Post Data:2009-04-17 12:57:04

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

EJB 3: Entity Bean Basic #Java Short Notes

Plain Java objects with persistence storage. They are not remotable and must be accessed through the new javax.persistence.EntityManager service. An entity bean implementation is provided in the following three files/classesBeansOrder.javaLineItem.javaEntity ManagerShoppingCartBean.java//Order.javaimport javax.persistence.CascadeType;import javax.persistence.Entity;import javax.persistence.FetchType;import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.OneToMany;import javax.persistence.Table;import javax.persistence.Id;import javax.persistence.CascadeType;import javax.persistence.FetchType;import java.util.ArrayList;import java.util.Collection;@Entity@Table(name = "PURCHASE_ORDER")public class Order implements java.io.Serializable{   private int id;   private double total;   private Collection lineItems;   @Id @GeneratedValue(strategy=GenerationType.AUTO)   public int getId()   {      return id;   }   public void setId(int id)   {      this.id = id;   }   public double getTotal()   {      return total;   }   public void setTotal(double total)   {      this.total = total;   }   public void addPurchase(String product, int quantity, 	double price)   {      if (lineItems == null) lineItems = new ArrayList();      LineItem item = new LineItem();      item.setOrder(this);      item.setProduct(product);      item.setQuantity(quantity);      item.setSubtotal(quantity * price);      lineItems.add(item);      total += quantity * price;   }   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, 	mappedBy="order")   public Collection getLineItems()   {      return lineItems;   }   public void setLineItems(Collection lineItems)   {      this.lineItems = lineItems;   }}//LineItem.javaimport javax.persistence.Entity;import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.JoinColumn;import javax.persistence.ManyToOne;import javax.persistence.Entity;@Entitypublic class LineItem implements java.io.Serializable{   private int id;   private double subtotal;   private int quantity;   private String product;   private Order order;   @Id @GeneratedValue(strategy=GenerationType.AUTO)   public int getId()   {      return id;   }   public void setId(int id)   {      this.id = id;   }   public double getSubtotal()   {      return subtotal;   }   public void setSubtotal(double subtotal)   {      this.subtotal = subtotal;   }   public int getQuantity()   {      return quantity;   }   public void setQuantity(int quantity)   {      this.quantity = quantity;   }   public String getProduct()   {      return product;   }   public void setProduct(String product)   {      this.product = product;   }   @ManyToOne   @JoinColumn(name = "order_id")   public Order getOrder()   {      return order;   }   public void setOrder(Order order)   {      this.order = order;   }}//ShoppingCartBean.javaInteracts with Order as a plain Java object. The checkout() method stores orders with persistence storage by using the required EntityManager service.import javax.ejb.Remote;import javax.ejb.Remove;import javax.ejb.Stateful;import javax.persistence.EntityManager;import javax.persistence.PersistenceContext;import javax.persistence.PersistenceContext;@Stateful@Remote(ShoppingCart.class)public class ShoppingCartBean implements ShoppingCart, 	java.io.Serializable{   @PersistenceContext   private EntityManager manager;   private Order order;   public void buy(String product, int quantity, double price)   {      if (order == null) order = new Order();      order.addPurchase(product, quantity, price);   }   public Order getOrder()   {      return order;   }   @Remove   public void checkout()   {      manager.persist(order);   }} GNU Distribution Without Warranty License

From: http://sitestree.com/?p=4834
Categories:Java Short Notes
Tags:
Post Data:2011-12-03 23:27:24

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

#Engineering: #Canada: #Job/Contract/Project: Any #Engineering: #Computer, #Electrical, #Electronics, #Civil, #Chemical, #Mechanical, #Naval, #Biomedical, and misc Engineering

Date Posted:2021-07-18 .Apply yourself, or submit others as candidates; Build a recruitment team to submit others as candidates; submit RFP to be considered for projects in future; Try to become a vendor so that you are asked to submit consultants/resources in future. If these work for you. This list is posted in this blog everyday provided there are new projects under the criteria

  1. construction-services-10004
  2. REGINA SOUTH SWITCHING STATION – CIVIL WORKS
  3. ET Kenney Electrical Upgrades
  • electrical-and-electronics-10006
  • Electrical Products (Door Locks) (W3330-22-111)
  • Electrical Wire Products
  • transportation-equipment-and-spares-10029
  • Fleet Lighting and Electrical Components
  • architect-and-engineering-services-10048
  • Install Doorway to Mechanical Pit for Elevator Maintenance
  • If & As Required Geotechnical Engineering Review Services
  • Professional Engineering Services – Street Reconstruction No. 4
  • Project Electrical Engineer- Peak Shavers NF 91 Project
  • RQQ-2020-NAFA-487: Engineering Services for Mount Joy Passing Track
  • Engineering Services-Brown Street, Sydney Mines-Waterline Upgrade
  • Engineering Services, CS 2-20 Twinning, North of Prince Albert
  • environmental-services-10050
  • If & As Required Geotechnical Engineering Review Services
  • Prime Consultant Landscape Architecture or Civil Engineering Consultant Services for David Thompson Corridor Infrastructure Safety Upgrades
  • natural-resources-services-10051
  • SP22TED251 – Mechanical Site Preparation – Excavator – Kamloops
  • Mechanical Site Preparation – Excavator – Kamloops Field Team
  • operation-of-government-owned-facilities-10039
  • Engineering Services for Intersection Improvement Program
  • professional-administrative-and-management-support-services-10040
  • If & As Required Geotechnical Engineering Review Services
  • NPP – W6399-21-LF84/B – TSPS – One (1) Intermediate Professional Engineer (P.Eng). (W6399-21-LF84/B)
  • research-and-development-r-d-10036
  • Software reverse engineering prototypes development (W7701-217332/A)
  • Engineering Services for Intersection Improvement Program
  • special-studies-and-analysis-not-r-d-10047
  • Engineering and Architectural Services
  • undefined-10055
  • RQQ-2020-NAFA-487: Engineering Services for Mount Joy Passing Track
  • Keywords Used:engineer,civil,mechanical,electrical,electronics,mechatronics,naval,biomedical,computer engineer,software engineer,civil engineer,biomedical,electrical engineer,electronics engineer,mechanical engineer,metallurgical,chemical engineer,industrial engineer,communications engineer,quality assurance engineer,Aerospace engineer,aeronautical engineer,Engineering manager,Agricultural Engineer,Automotive Engineer,Environmental Engineer,Geological Engineer,Marine Engineer,Petroleum Engineer,Acoustic Engineer,Acoustic Engineer,Aerospace Engineer,Agricultural Engineer,Applied Engineer,Architectural Engineer,Audio Engineer,Automotive Engineer,Biomedical Engineer,Chemical Engineer,Civil Engineer,Computer Engineer,Electrical Engineer,Environmental Engineer,Industrial Engineer,Marine Engineer,Materials Science Engineer,Mechanical Engineer,Mechatronic Engineer,Mining and Geological Engineer,Molecular Engineer,Nanoengineering,Nuclear Engineer,Petroleum Engineer,Software Engineer,Structural Engineer,Telecommunications Engineer,Thermal Engineer,Transport Engineer,Vehicle Engineer,engineering

    #Canada: #IT Jobs:#Consultants, #Contractors, #Analysts, #Engineers, #Developers, #Technology Consultants, #IT-Consultants Opportunities2021-07-18

    Apply yourself, or submit others as a candidate, Build a recruitment team to submit others as a candidate, submit RFP to be considered for projects in future, Try to become a vendor so that you are asked to submit consultants/resources in future

    1. edp-hardware-and-software-10034
    2. Project: tender_15205 – 21-004P Cloud-Based Web Services
    3. energy-10007
    4. Source List (SL) for Environmental Consulting Services
    5. Prime Consultant for Main Building Foundation Repairs & Site Grading
    6. architect-and-engineering-services-10048
    7. Consulting Services: Archibald Drive Storm Sewers
    8. RFP for PRIME ARCHITECTURAL CONSULTANT SERVICES for CALGARY ROCKYVIEW GENERAL HOSPITAL Intensive Care Unit/ Coronary Care Unit/ Gastrointestinal Clinic Redevelopment
    9. communications-photographic-mapping-printing-and-publication-services-10042
    10. Environmental and Survey Consultant Services for Highway-774 Wildlife Road Crossing Study and Fence Line Survey
    11. educational-and-training-services-10043
    12. Assessment Consulting Service for the Assured Income for the Severely Handicapped (AISH) Program for the Province of Alberta
    13. Anti-Racism & Anti-Discrimination Exploratory Working Group (AREWG) Consultant
    14. environmental-services-10050
    15. Environmental and Survey Consultant Services for Highway-774 Wildlife Road Crossing Study and Fence Line Survey
    16. Prime Consultant Landscape Architecture or Civil Engineering Consultant Services for David Thompson Corridor Infrastructure Safety Upgrades
    17. financial-and-related-services-10038
    18. Group Insurance Consulting (EP899-220446/A)
    19. RQQ-2020-FACA-499: VOR + 2nd Stage- Provide Accounting & Tax Consulting Services
    20. Request for Proposal (RFP) for Actuarial and Pension Consulting Services
    21. information-processing-and-related-telecommunications-services-10049
    22. Business Consulting and Risk Management (20210074)
    23. Project: tender_15205 – 21-004P Cloud-Based Web Services
    24. REFONTE DES SITES WEB
    25. professional-administrative-and-management-support-services-10040
    26. RFP for PRIME ARCHITECTURAL CONSULTANT SERVICES for CALGARY ROCKYVIEW GENERAL HOSPITAL Intensive Care Unit/ Coronary Care Unit/ Gastrointestinal Clinic Redevelopment
    27. NPP – W6399-21-LF84/B – TSPS – One (1) Intermediate Professional Engineer (P.Eng). (W6399-21-LF84/B)
    28. TSPS 2.5 – Business Process Consultant (Senior) (W0152-22-AA034)
    29. TSPS 2.3 Business Consultant (Senior) (W0152-22-AA035)
    30. special-studies-and-analysis-not-r-d-10047
    31. CONSULTING SERVICES FOR STREETSCAPE ASSESSMENT
    32. Anti-Racism & Anti-Discrimination Exploratory Working Group (AREWG) Consultant
    33. #Sensor: #Canada: #Job/Contract/Project: #Sensor, #Tracking, #Fusion, #Estimation, #Surveillance, #sensor network, #target #tracking, #security 2021-07-18

      Date Posted:2021-07-18 .Apply yourself, or submit others as candidates; Build a recruitment team to submit others as candidates; submit RFP to be considered for projects in future; Try to become a vendor so that you are asked to submit consultants/resources in future. If these work for you. This list is posted in this blog everyday provided there are new projects under the criteria

      1. armament-10027
      2. Signal Smoke Marine, Orange (W8486-217390/A)
      3. communications-detection-and-fibre-optics-10031
      4. LEED Recognition Display
      5. construction-products-10032
      6. LEED Recognition Display
      7. electrical-and-electronics-10006
      8. LEED Recognition Display
      9. Surveillance of Space 2 RFI (W8474-187639/C)
      10. fire-fighting-security-and-safety-equipment-10010
      11. Smart Anti-Loitering and Security System
      12. textiles-and-apparel-10028
      13. LEED Recognition Display
      14. architect-and-engineering-services-10048
      15. RFP – Building Perimeter – Access Point Security
      16. communications-photographic-mapping-printing-and-publication-services-10042
      17. LEED Recognition Display
      18. custodial-operations-and-related-services-10037
      19. LEED Recognition Display
      20. environmental-services-10050
      21. LEED Recognition Display
      22. information-processing-and-related-telecommunications-services-10049
      23. LEED Recognition Display
      24. research-and-development-r-d-10036
      25. Surveillance of Space 2 Ground-Based Optical System Request for Information (W8474-207923/B)
      26. ITS Operational Security Services
      27. utilities-10041
      28. LEED Recognition Display
      29. Keywords Used:sensor,fusion,sensor network,tracking,target tracking,surveillance,self driving car,self-driving,estimation,security,signal processing,image processing,autonomouse vehicle,facial recognition,signal,recognition,sensor fusion

        EJB 3: Statefull EJB #Java Short Notes

        States need to be maintained between calls. In EJB3 all beans are homeless [no home interface]//ShoppingCartBean.javaimport java.io.Serializable;import java.util.HashMap;import javax.ejb.Remove;import javax.ejb.Stateful;import javax.ejb.Remote;@Stateful@Remote(ShoppingCart.class)public class ShoppingCartBean implements ShoppingCart, Serializable{   private HashMap cart = new HashMap();   public void buy(String product, int quantity)   {      if (cart.containsKey(product))      {         int currq = cart.get(product);         currq += quantity;         cart.put(product, currq);      }      else      {         cart.put(product, quantity);      }   }   public HashMap getCartContents()   {      return cart;   }   @Remove   public void checkout()   {      System.out.println("To be implemented");   }}//ShoppingCart.java//remote interfaceimport java.util.HashMap;import javax.ejb.Remove;public interface ShoppingCart{   void buy(String product, int quantity);   HashMap getCartContents();   @Remove void checkout();}//client//Client.java//client uses JNDI to look up for EJB servicesimport java.util.HashMap;import javax.naming.InitialContext;import org.jboss.tutorial.stateful.bean.ShoppingCart;public class Client{   public static void main(String[] args) throws Exception   {      InitialContext ctx = new InitialContext();      ShoppingCart cart = (ShoppingCart) ctx.lookup("ShoppingCartBean/remote");      System.out.println("Buying 1 memory stick");      cart.buy("Memory stick", 1);      System.out.println("Buying another memory stick");      cart.buy("Memory stick", 1);      System.out.println("Buying a laptop");      cart.buy("Laptop", 1);      System.out.println("Print cart:");      HashMap fullCart = cart.getCartContents();      for (String product : fullCart.keySet())      {         System.out.println(fullCart.get(product) + "     " + product);      }      System.out.println("Checkout");      cart.checkout();      System.out.println("Should throw an object not found exception        by invoking on cart after @Remove method");      try      {         cart.getCartContents();      }      catch (javax.ejb.EJBNoSuchObjectException e)      {         System.out.println("Successfully caught no such object exception.");      }   }}

        From: http://sitestree.com/?p=4833
        Categories:Java Short Notes
        Tags:
        Post Data:2008-11-20 09:48:27

        Shop Online: https://www.ShopForSoul.com/
        (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
        In Bengali: http://Bangla.SaLearningSchool.com
        http://SitesTree.com
        8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
        Shop Online: https://www.ShopForSoul.com/
        Medium: https://medium.com/@SayedAhmedCanada

        EJB 2: How to build a stateless EJB #Java Short Notes

        EJB 2: How to build a stateless EJB

        1. Install an EJB Server
        2. Specify the EJB Remote Interface
        3. Specify the Home Interface
        4. Write the EJB bean Class
        5. Create the ejb-jar File
        6. Deploy the EJB bean
        7. Write the EJB Client
        8. Run the Client

        From: http://sitestree.com/?p=4832
        Categories:Java Short Notes
        Tags:
        Post Data:2007-03-12 03:44:24

        Shop Online: https://www.ShopForSoul.com/
        (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
        In Bengali: http://Bangla.SaLearningSchool.com
        http://SitesTree.com
        8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
        Shop Online: https://www.ShopForSoul.com/
        Medium: https://medium.com/@SayedAhmedCanada

        EJB 3: Stateless Bean #Java Short Notes

        No need to maintain the state of a bean between calls. //CalculatorBean.java@Statelesspublic class CalculatorBean implements CalculatorRemote, CalculatorLocal{   public int add(int x, int y)   {      return x + y;   }   public int subtract(int x, int y)   {      return x - y;   }}//CalculatorRemote.javaimport javax.ejb.Remote;@Remotepublic interface CalculatorRemote extends Calculator{}//CalculatorLocal.java import javax.ejb.Local;@Localpublic interface CalculatorLocal extends Calculator{}//Client.javaimport tutorial.stateless.bean.Calculator;import tutorial.stateless.bean.CalculatorRemote;import javax.naming.InitialContext;public class Client{   public static void main(String[] args) throws Exception   {      InitialContext ctx = new InitialContext();      Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");      System.out.println("1 + 1 = " + calculator.add(1, 1));      System.out.println("1 - 1 = " + calculator.subtract(1, 1));   }}

        From: http://sitestree.com/?p=4831
        Categories:Java Short Notes
        Tags:
        Post Data:2011-05-30 17:27:29

        Shop Online: https://www.ShopForSoul.com/
        (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
        In Bengali: http://Bangla.SaLearningSchool.com
        http://SitesTree.com
        8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
        Shop Online: https://www.ShopForSoul.com/
        Medium: https://medium.com/@SayedAhmedCanada