Developing e commerce-apps_oracle_and_java


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Developing e commerce-apps_oracle_and_java

  1. 1. Developing e-Commerce Applications UsingOracle and Java Megh Thakkar Director of Database Technologies Quest Software
  2. 2. Industry Directions Web Based Companies E-Commerce Brick and Mortar
  3. 3. e-Commerce Challenges High Availability (24*7*365/366) Performance Scalability Security / Hackers
  4. 4. Reality CheckCompany Outage Cost Results June 12, 1999 26% stock priceeBay $3-5 Million 22 hours dropAT&T April 13, 1998 $40 Million Changed 26 hours in rebates infrastructure Upgrade April 6, 1996 $3 MillionAOL infrastructure 24 hours in rebates $80 Million Feb 24-Apr 21, 99 UpgradeCharles Schwab undetermined infrastructure 4 hours $70 Million Loss of integrityBank of Singapore July 1-8, 1999 undetermined and interest $10 Million Key betting daysTabcorp Australia October 1999 in rebates lost 22% stock priceE*Trade March 3-4, 1999 undetermined drop
  5. 5. Important Java Features  Object-oriented language  It allows the development of applications using an open standard  It enables the development of portable applications  It allows the reuse of code by means of JavaBeans and Enterprise JavaBeans (EJB) resulting in improved productivity  It can execute in browsers, application servers, and databases  It allows applications to be deployed in two-tier and multi-tier configurations
  6. 6. When to use Java?  CPU-intensive “number crunching” operations  To overcome PL/SQL limitations - Host command - Limitations with UTL_SMTP  Extend the client types  When object-oriented features are more suitable REMEMBER THAT JAVA IS CASE-SENSITIVE
  7. 7. PL/SQL Packages and TheirJava Equivalents Standard PL/SQL Equivalent Java implementation package DBMS_ALERT No pure Java equivalent. DBMS_DDL JDBC has an equivalent mechanism for this. DBMS_JOB No pure Java equivalent. DBMS_LOCK No pure Java equivalent. DBMS_MAIL JavaMail DBMS_OUTPUT DBMS_JAVA.SET_STREAMS can be used to redirect System.out to DBMS_OUTPUT. The standard Java OutputStream api can be used with the subclass oracle.aurora.rdbms.OracleDBMSOutputStream DBMS_SESSION JDBC can be used to execute ALTER SESSION DBMS_SQL JDBC can be used. DBMS_UTILITY No pure Java equivalent UTL_FILE Classes File, FileOutputStream and FileInputStream. Use of these classes requires the granting of JAVAUSERPRIV privilege.
  8. 8. Java Server Platforms Two related Java execution environments are provided in Oracle9i:  Oracle JServer VM that is integrated with Oracle9i allowing data intensive Java logic to run and  Java VM integrated with Oracle Application Server (iAS) as a Java cartridge
  9. 9. Ensuring JVM Setup Select count(*) from dba_objects where object_type like ‘JAVA%’; Select dbms_java.longname(name) from sys.obj$ where type# = 29 and status != 1;
  10. 10. Configuration Tips  Use MTS  Configure Large pool
  11. 11. Checking IIOP Connectivity  Lsnrctl services  netstat  sess_sh
  12. 12. Support for Different Types ofApplication Developers  Database programmers can write traditional stored procedures, triggers and object-relational methods in Java  Component-based Java developers can write reusable server code in the form of Enterprise Java Beans  Distributed system developers can develop CORBA servers in Java  Web developers can use Java Server Pages to embed Java tags in HTML pages to dynamically generate HTML pages directly from Oracle9i
  13. 13. Client-side ProgrammaticInterface Oracle9i provides two different client-side programmatic interfaces for Java developers:  JDBC (Four types)  SQLJ (allowing SQL to be embedded in Java)
  14. 14. Choosing the Appropriate JDBCDriver Fr ee at u JOr DCi B Iv C dr e Jt d r Dh r Bi i Cnve S rr l N u t a to p fps p op o e Y e s S rr * A Qt u t S el L p f Q tl * p oL o N SeN OT P nC i lP s y/I aer dre as p a t sr ut pe pd o s r id u t ni p ec n p dl g o u IN P Pa i Cm p ,e e d s aC nP d/ TPI Ep nt ci ro yn Y B ih Nu t e y ne op e s u t . sg tp d sr o A c ek det v dw a Nr n o OnN p ot t f8 i o e D re r t i y v p e T 2 vJ T4 v y d r By d r p r . Cp r . e i D e e ie if a na r tc e ee rs M ufa a s J k e a e ov s i m dt st c c me t pn h lt a ee os o t c tn k on e e u C i ad t o s I n ci l a e t t tr y n O oer e t c wtr iha t ec h Oe Oe a l r da a as c te l b da as te a b
  15. 15. Choosing the Right Tool Characteristics Enterprise Jdeveloper WebDB (portals) developer suite: Suite (+ UML): Designer, Java IDE, BC4J, Developer, UML Modeling Developer Server Interactive Best Good Good user interface Single point of Good Better Best access to corporate services E-Commerce Intranet-based Internet- Internet- support based based Programming PL/SQL-based; Java-based; Java-based; model declarative component component model model model Mature & proven Yes Partial No technology Web enabling Best Good Good legacy systems
  16. 16. Challenges in Developing aScalable Java Environment  Interaction of threads and automated storage management or garbage collection  Achieving minimum incremental per-user session footprint  Java executes platform-independent byte codes on top of a virtual machine. The virtual machine then deals with the specific hardware platform. This makes the execution slightly inefficient
  17. 17. Garbage Collection Issues Garbage collection is a major aspect of the Java language’s automated storage management mechanism  Although Oracle9i supports Java language level threads, all Java code in Oracle9i executes as a call within a session  Java programs can use the same scalability architecture used by Oracle internally  The garbage collector used in Oracle9i Java virtual machine never collects garbage from more than one user at any time  Each user experiences as if she is executing her own Java code in her own virtual machine
  18. 18. Factors Affecting Footprint  Size of the program This is determined by the number of classes and methods and the amount of code they contain.  Program complexity Amount of core class libraries used as the program executes  State objects used This depends upon the number of objects allocated, their size and how many are retained across calls  Ability of the garbage collector and memory manager to cope with the demands of the program
  19. 19. Reducing Footprint  Footprint can be reduced by sharing resources across Java processes  Release large data structures at end-of-call  Data structures that are candidates for end-of-call optimization include: - Buffers or caches - Static fields - Dynamically built data structures
  20. 20. Initialization Parameters  The following parameters affect memory usage and performance of Java code: - shared_pool_size - java_pool_size - java_soft_sessionspace_limit (default 1MB) - java_max_sessionspace_size (ORA-29554) (default 4GB) SELECT * FROM v$sgastat WHERE pool = ‘java pool’;
  21. 21. Improving Speed of Execution  Use natively compiled code such as core Java class libraries and Oracle-provided Java code
  22. 22. Oracle9i Solutions for Increasingthe Concurrent Connections  Multi-Threaded Server  Connection manager  Connection pooling  Orastack (Windows NT only)
  23. 23. Multi-threaded Server  Allows many user threads to share very few server threads  User threads connect to a dispatcher process which routes client requests to the next available server thread Result: More users are supported
  24. 24. Connection Manager  Concentrates multiple clients into a single multiplexed data connection  Clients can use different protocols Result: Applications can be used continuously by the clients
  25. 25. Connection Pooling  Places idle users in a suspended mode and reassigns their physical connections until they become active again Result: Ideal for users that need to be logged on all the time but don’t need to really use the application
  26. 26. Orastack  Can be used to change the default reserved stack space used by each Oracle thread USE WITH EXTREME CAUTION Result: Allows more user connections
  27. 27. Using PL/SQL in JAVA – PL2Java  Part of the iAS product  Must first install DBMS_PACKAGE in the SYS schema  Generates JAVA wrapper classes for PL/SQL procedures and functions in PL/SQL packages  The wrapper classes can be called from the JAVA programs to invoke the PL/SQL program units Syntax: pl2java username/password@connect-string plsql_package
  28. 28. Java Server Pages  HTML pages with JAVA as the embedded language  Different from mod_plsql (or PL/SQL cartridge)  JSPs cache compiled code  Creation, compilation and execution of servlets is handled by the JSP engine
  29. 29. Java Security  Oracle 8.1.5 allows security through roles  Oracle 8.1.6 and above allows roles as well as Java 2 security  initjvm.sql creates 2 roles: JAVAUSERPRIVS (open a TCP/IP socket; read/write file using UTL_FILE_DIR) JAVASYSPRIVS (all privs from JAVAUSERPRIVS + create subprocess, set socket factory, set stream handler, listen on specific ports)  Use DBMS_JAVA package  Views: DBA_JAVA_POLICY and USER_JAVA_POLICY