300 likes | 505 Views
Developing e-Commerce Applications Using Oracle and Java. Megh Thakkar Director of Database Technologies Quest Software. Industry Directions. Web Based Companies. E-Commerce. Brick and Mortar. e-Commerce Challenges. High Availability (24*7*365/366). Performance. Scalability.
E N D
Developing e-Commerce Applications Using Oracle and Java • Megh Thakkar • Director of Database Technologies • Quest Software
Industry Directions Web Based Companies E-Commerce Brick and Mortar
e-Commerce Challenges High Availability (24*7*365/366) Performance Scalability Security / Hackers
Reality Check Company Outage Cost Results 26% stock price drop June 12, 1999 22 hours eBay $3-5 Million AT&T Changed infrastructure April 13, 1998 26 hours $40 Million in rebates Upgrade infrastructure $80 Million $3 Million in rebates April 6, 1996 24 hours AOL Upgrade infrastructure $70 Million Feb 24-Apr 21, 99 4 hours Charles Schwab undetermined Loss of integrity and interest undetermined July 1-8, 1999 Bank of Singapore Key betting days lost $10 Million in rebates October 1999 Tabcorp Australia 22% stock price drop undetermined March 3-4, 1999 E*Trade
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
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
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
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;
Configuration Tips • Use MTS • Configure Large pool
Checking IIOP Connectivity • Lsnrctl services • netstat • sess_sh
Support for Different Types of Application 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
Client-side Programmatic Interface Oracle9i provides two different client-side programmatic interfaces for Java developers: • JDBC (Four types) • SQLJ (allowing SQL to be embedded in Java)
Challenges in Developing a Scalable 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
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
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
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
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’;
Improving Speed of Execution • Use natively compiled code such as core Java class libraries and Oracle-provided Java code
Oracle9i Solutions for Increasing the Concurrent Connections • Multi-Threaded Server • Connection manager • Connection pooling • Orastack (Windows NT only)
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
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
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
USE WITH EXTREME CAUTION Orastack • Can be used to change the default reserved stack space used by each Oracle thread Result: Allows more user connections
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
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
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
BUY QUEST PRODUCTS THANK YOU FOR LISTENING