{"id":66322,"date":"2021-07-18T11:24:36","date_gmt":"2021-07-18T15:24:36","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/java-connector-overview-and-an-example-java-short-notes\/"},"modified":"2021-07-18T11:24:36","modified_gmt":"2021-07-18T15:24:36","slug":"java-connector-overview-and-an-example-java-short-notes","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=66322","title":{"rendered":"Java Connector Overview and an Example #Java Short Notes"},"content":{"rendered":"<ul>\n<li> Java Connector Architecture (JCA) enables integration of the J2EE components to any Enterprise Information Systems (EIS). EIS can be heterogeneous where scalability is a must. <\/li>\n<li> JDBC assumes DBMS\/RDBMS in the back-end, JCA targets any kind of EIS.<\/li>\n<li> One of the key parts of JCA is the Resource Adapter &#8211; usually a part of the application servers. Multiple resource adapters can be used to connect to different EISs of heterogeneous types.<\/li>\n<li> When resource adapters are plugged into the Application Servers they provide necessary transaction, security, and connection pooling mechanisms<\/li>\n<li> In the JCA, an application contract defines the API that provides the client view to access EISs. The API can be EIS\/resource adapter specific or standard.<\/li>\n<li> Common Client Interface (CCI) &#8211; a set of interfaces and classes that allows J2EE applications to interact with heterogeneous EISs.<\/li>\n<li> Example of JCA\n<ul>\n<li> EJBs, Servlets can connect to EISs through CCI and then access the EISs as required<\/li>\n<li> J2EE SDK provides a black box resource adapter that we will use in our example to connect to EISs. We will assume RDBMS as the EIS in the example<\/li>\n<li> Example: The flow of the application: client-&gt;servlet-&gt;resource adapter-&gt;EIS Tier (RDBMS &#8211; stored procedure)<\/li>\n<li> In a servlet example: first step: import javax.resource.cci.*;<\/li>\n<li> javax.resource.cci.*; &#8211; for ResourceException class<\/li>\n<li> import cci blackbox classes: import com.sun.connector.cciblackbox.*;<\/li>\n<li> Also, import servlet and application specific classes<\/li>\n<li>\n<pre>public class ExampleServletConnector extends HttpServlet{   private Connection con;   private ConnectionFactory cf;   private String user;  public void init() throws ServletException{      try{            \/\/establish JNDI interface            InitialContext ic = new InitialContext();           \/\/look up user and password           user = (String) ic.lookup(\"java:comp\/env\/user\");           String password = (String) ic.lookup(\"java:comp\/env\/password\");          \/\/reference to the connection factory for the CCI black box resource adapter - coded name CCIEIS          cf = (ConnectionFactory) ic.lookup(\"java:comp\/env\/CCIEIS\");         \/\/collect connection specification, connect to the database         ConnectionSpec conSpec = new ConnectionSpec (user,password);       con = cf.getConnection(conSpec);      }catch(ResourceException rex){         rex.printStackTrace();      }catch(NamingException nex){        nex.printStackTrace();      }  }<\/pre>\n<\/li>\n<li> Now define the doGet method for processing. An example doGet method is as follows<\/li>\n<li>\n<pre>public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException {  PrintWriter output = null;  res.setContentType(\"text\/html\");  try{     PrintWriter out = res.getWriter();     \/\/find the number of rows in the account table - check getAccountAccountCount method in the next item     int accCount = getAccountAccountCount();     out.println(\"Account Count\" + accCount);  }catch(Exception ex){   ex.printStackTrace();  }}<\/pre>\n<\/li>\n<li> getAccountAccountCount() method: to query the database and determine the number of rows in the account table<\/li>\n<li>\n<pre>public int getAccountCount(){   int count = -1;   try{       Interaction ix = con.createInteraction();       CciInteractionSpec iSpec = new CciInteractionSpec();        iSpec.setSchema(user);        iSpec.setCatalog(null);        \/\/stored procedure name to calculate the number of rows       iSpec.setFunctionName(\"ACCOUNTCOUNT\");       RecordFactory rf = cf.getRecordFactory();       IndexedRecord iRec = rf.createIndexedRecord(\"InputRecord\");       Record oRec = ix.execute(iSpec, iRec);       Iterator it = ((IndexedRecord)oRec).iterator();       \/\/process        while(it.hasNext()){          Object obj = it.next();          if (obj instanceof Integer){             count = ((Integer) obj).intValue();          }else if (obj instanceOf BigDecimal){           count = ((BigDecimal) obj).intValue();          }        }   }catch(Exception ex){   }   return count;}<\/pre>\n<\/li>\n<li> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p> From: http:\/\/sitestree.com\/?p=4956<br \/> Categories:Java Short Notes<br \/>Tags:<br \/> Post Data:2010-01-15 20:19:20<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Connector Architecture (JCA) enables integration of the J2EE components to any Enterprise Information Systems (EIS). EIS can be heterogeneous where scalability is a must. JDBC assumes DBMS\/RDBMS in the back-end, JCA targets any kind of EIS. One of the key parts of JCA is the Resource Adapter &#8211; usually a part of the application &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=66322\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-66322","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":66334,"url":"http:\/\/bangla.sitestree.com\/?p=66334","url_meta":{"origin":66322,"position":0},"title":"Java 2 Security Architecture #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Security Services Provide Data Integrity Data Confidentiality Access Control - Authentication and Authorization Encryption helps to provide such security services Core Java Security Architecture -- Core Java 2 Security Architecture -- Java Cryptography Architecture (JCA) -- Java Cryptography Extension (JCE) -- Java Secure Socket Extension (JSSE) -- Java Authentication and\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66340,"url":"http:\/\/bangla.sitestree.com\/?p=66340","url_meta":{"origin":66322,"position":1},"title":"Core J2EE Component Technologies #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Core J2EE Component Technologies J2EE Application Components: Web Components, Business Components Web-Component: Software entity hosted by a web-container on a J2EE Server Generate user interface for web-based applications Two Types: Servlets, JSPs Servlets: Process requests dynamically, format responses JSPs: How to process requests, and format responses Business Components: EJB Components\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66338,"url":"http:\/\/bangla.sitestree.com\/?p=66338","url_meta":{"origin":66322,"position":2},"title":"J2EE Architecture: J2EE Design Patterns: Related Concepts #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Design Patterns What are design patterns? Design patterns are specific\/(context-based) solutions\/approaches to address specific problems\/situations. Some problems are general\/open problems and very common problems in a particular type of applications. Design patterns can be created to solve such problems in a specific context and that can be re-used every time\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67414,"url":"http:\/\/bangla.sitestree.com\/?p=67414","url_meta":{"origin":66322,"position":3},"title":"Hibernate Architecture: Some Information #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 21, 2021","format":false,"excerpt":"Lite Architecture: Applications provide their own JDBC connections and also manage their own transactions Full Cream Architecture: Hibernate takes care of the JDBC connections and transaction Management. The applications are relieved of these responsibilities An instance of a persistent class can be in one of three states such as transient,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66421,"url":"http:\/\/bangla.sitestree.com\/?p=66421","url_meta":{"origin":66322,"position":4},"title":"Key J2EE  Components : Basic Concepts with Examples #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 19, 2021","format":false,"excerpt":"Java EE 5 (J2EE 5) uses XML deployment descriptors for the configuration of the web-applications and web-components. What Java EE provides? It provides the internal framework\/structure\/system level capability\/system-level infrastructure to support large enterprise level applications with features like distributed database, distributed computing , security, and transaction management. J2EE also provides\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67690,"url":"http:\/\/bangla.sitestree.com\/?p=67690","url_meta":{"origin":66322,"position":5},"title":"Basic Java But Essential Knowledge for exams like SCJA, or to the project managers new to Java technologies #Computer Game Design #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 27, 2021","format":false,"excerpt":"By definition an enumerated type is a finite set of symbolic literals In Java an enumerated type is represented as first-class object. Enumerated type literals are allowed in case statements. The literals of an enumerated type may be of any valid Java identifier An interface may NOT contain any concrete\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/66322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66322"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/66322\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66322"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}