Introduction

 

The time for action is now. It’s never too late to do something.

 
 --Antoine de Saint Exupery

The traditional division of labor between the RDBMS—manages SQL, XML, text, and binary data—and the application server—runs applications (i.e., business logic and presentation logic)—is obsolete. First, relational databases now host frameworks and run packages that furnish data services; they also communicate with the external world through standard mechanisms such as JDBC, RMI, HTTP, and IIOP. Second, the traditional application servers have been subsumed by the more comprehensive and integrated application platform suites,[1] which comprise the core J2EE containers (or equivalent) and a broad set of frameworks, including HTTP listeners, Web services, enterprise integration, portals, Web caches, business intelligence, report, wireless, and so on. Ultimately, the RDBMS, the application platform suite, higher-level ERP (e.g., Oracle E-Business Suite, SAP), and collaboration frameworks (e.g., Oracle Collaboration Suites) will all interoperate through standard protocols or middleware such as the emerging enterprise service bus.[2] At a humble and immediate scale, this book will address server-side database programming (i.e., programming models that run within the database) as well as client-side database programming (i.e., programming models that run in the middle tier or client tier, against the database).

This book is organized into six parts. Part I will look at Java in the database: the requirements, the programming model, and the various pragmatic applications. Part II (JDBC), Part III (SQLJ), and Part IV (JPublisher) will address the requirements and APIs for Java SQL data access, as well as advanced techniques for connecting Java/J2EE applications to clustered databases. Part V will focus on database Web services, the requirements, the techniques, and concrete examples. Finally, Part VI will put everything together and illustrate how far developers can go using Java in the database, using JDBC, J2EE, Web services, and SQL together. An introduction to Oracle, Java, and Web services is beyond the scope of this book; a minimal knowledge of Java, JDBC, SQL, Oracle RDBMS, and PL/SQL is required.

Server-Side Database Programming (Stored Procedures)

Stored procedures are traditionally used to encapsulate a batch of CRUD[3] operations, but in this book, we will look at advanced and more powerful usage. Imagine database-resident frameworks (i.e., code running in the database)—homegrown (see “Putting Everything Together”) or packaged database frameworks such as Oracle iMedia (see Chapter 17)—exposing their entry points as stored procedures (i.e., the tip of the iceberg), and you will get an idea of the power of this programming model.

Database Programming Using Java in the Database

Java is a complete, portable, object-oriented, safe, flexible, and versatile language, but why consider it when it comes to database programming? Well, this is the whole purpose of Part 1 of this book, but let’s say in a nutshell that the integration of a Java engine (J2SE) with a database engine, closer to the data, gives you the best of both worlds and opens the door to powerful, versatile/flexible, and sophisticated data-driven applications that are not possible with non-Java-enabled RDBMS. The greatest benefit Java brings to the database is the ability to implement data-driven functionalities or services, by just reusing the huge set of Java libraries, with minor changes, directly in the database, resulting in an extraordinary productivity and cost savings. These libraries solve concrete problems such as custom enterprise integration, advanced image processing, Excel-like expressions to SQL transformers, and a set of outbound capabilities including JDBC callout to remote databases, HTTP callout to Web components (i.e., Servlet and JSP), callout to RMI servers, RMI/IIOP callout to EJB and CORBA objects, and SOAP/ HTTP callout to external Web services. Several RDBMS support Java for writing stored procedures; however, the level of integration of Java with the RDBMS engine varies from one vendor to another.

In this book, I will focus on Oracle’s implementation, which is by far the most integrated, as discussed in Chapter 2. I will discuss the rationale for running Java in the database as opposed to Java outside the database. This book covers Oracle 9i R2, up to Oracle Database 10g Release 2.[4] At platform level, Java in the database complements Java/J2EE in the middle tier; applications can be partitioned or migrated across tiers.

DBAs are adamant when it comes to data security or data integrity breaches that might originate in code running in “their” database but foreign to them and outside their control. This book is your opportunity to regain control or confidence in Java in your database, or at least be knowledgeable enough to discuss it with the Java geeks. You will see that Java code cannot surreptitiously be downloaded from the Internet and run in your database without your explicit consent; in other words, Java runs even safer in the database. With the emergence of self-managed databases that require less DBA time, you will be expected to manage more databases to support an increasing number of applications, but also be involved in the support of data-driven applications and the deployment of Java and Web-enabled products.[5] The techniques described in this book will help you extend your skill set in these areas, thereby strengthening your position. If you love PL/ SQL, you will see that Java in the database complements and opens new frontiers to PL/SQL.

In Chapter 2, I will take you inside the Java runtime in the database (i.e., OracleJVM). I will explain its architecture, memory management, byte-code interpreter, and native compiler, but more important, I will provide performance tips. In Chapter 3, I will explain the necessary steps for developing and deploying Java applications in the database. In Chapter 4, I will describe advanced database applications as well as practical code samples in terms of data conversions and callout to external Web components, EJB components, ERP frameworks, external databases, and external Web services. These are building blocks for more complete applications such as the TECSIS custom integration framework and Corporate Online (see “Putting Everything Together”). Scripting languages are becoming more and more popular for RAD and Web publishing; in Chapter 5, I will show you how you can run non-Java scripts written in TCL, PYTHON, SCHEME, and GROOVY in the Oracle database, using the OracleJVM.

Database Programming Using JDBC, SQLJ, and JPublisher

When it comes to database programming, Java in the database is just one side of the coin. The other side of the coin is made of JDBC and SQLJ. These APIs are used both within Java in the database and also with J2EE/ J2SE in the middle tier, and J2SE (Applets) in the client tier to access and invoke database operations and applications. In Part II, III, and IV of the book I will investigate JDBC, SQLJ, and Oracle JPublisher.

The Good Old JDBC

Used by millions of Java applications to persist Java states in RDBMS either explicitly, or under the covers, JDBC has evolved from a mere call-level interface API modeled from ODBC to a complete data access middleware and a key player in enterprise applications development and deployment. Beyond the standard API, vendors such as Oracle have taken JDBC one step further by adding scalability, high availability, debugging, diagnostic ability, tracing, and logging capabilities in clustered databases and grid environments.

JDBC and Grid Computing

Servers consolidation, resource virtualization, and provisioning—in other words, enterprise grid computing—aims at consolidating IT resources (infrastructure and applications) and optimizing their usage, thereby cutting costs substantially. Enterprise grid computing put new requirements on RDBMS, such as reliably deploying over a farm of servers to allow thousands of concurrent users to efficiently access peta-bytes of data. Consequently, deploying Java and J2EE applications against a Grid-enabled database poses a set of new challenges to JDBC. I will describe new connection services in Oracle JDBC drivers, including the advanced connection caching, fail-over, and load-balancing mechanisms in RAC and GRID environments.

In Chapter 6, I will introduce the JDBC technology and Oracle’s implementation. In Chapter 7, I will describe the essential JDBC structures, and then we’ll look at type mapping in Chapter 8; finally in Chapter 9, we’ll look at JDBC best practices and performance tips.

SQLJ: Bundling SQL and Java Together

For those who find JDBC programming cumbersome, the ANSI ISO SQLJ Part 0,[6] which specifies the integration of SQL statements in Java programs, came to the rescue. SQLJ is to JDBC what JavaServer Pages are for Java Servlets; it simplifies JDBC programming. However, SQLJ is not part of the Enterprise Java platform (i.e., J2EE), hence its adoption is mostly among database developers. In Chapters 10, 11, and 12, I will cover the SQLJ technology and Oracle’s implementation.

JPublisher: The Java Developer’s Swiss Army Knife for Accessing the Oracle Database

If you are handling Java persistence programmatically, neither JDBC nor SQLJ allows you to easily map complex database types such as object types, object type references, and user-defined SQL types. Oracle JPublisher is a pure Java utility that simplifies SQL data access as well as publishing database entities to Java and Web services. In Chapter 13, I will show you how to avoid the pains of JDBC programming (if any) using JPublisher.

Database Programming with Web Services

Web services refer to core technologies (SOAP, WSDL, UDDI) that allow client applications to access remote applications as services (currently, mostly through HTTP). At the database level, this translates into the ability to invoke database operations through Web services mechanisms (i.e., SOAP, WSDL) without using vendor-specific protocols and through the Internet. Database Web services extend the client base of the database (i.e., inbound/inward reach) to heterogeneous environments and unconnected applications. Similarly, the ability to access remote data as dynamic data (i.e., data produced on demand), using Web services mechanisms and federating such data with resident data, extends the outreach of the database. In Part V of this book, I will describe Oracle’s implementation of database Web service[7] s and how it leverages all technologies available in the Oracle database, including SQL, PL/SQL, Streams AQ, XDB, Java-in-the-Database, JDBC, SOAP, and HTTP. Beyond bare Web services, the industry is geared toward the service-oriented architecture (SOA), to help consolidate enterprise resources and expose these through standard Internet and Web services mechanisms, thereby optimizing their utilization and reducing costs. Chapter 14 will cover Web services and SOA for DBAs, data architects, and others. In Chapter 15, we will look at how you can turn your Oracle database into a Web services provider and first-class member of your SOA. In Chapter 16, we will examine how you can invoke external Web services from within the database.

Putting Everything Together: The “All-You-Can-Eat Buffet”

In this final part of the book (Chapter 17), I will describe real-life customer case studies, which implement many of the technologies described so far. The TECSIS/Tenaris and CorporateOnline case studies are the best illustrations of combining Java, Web services, and database capabilities. These case studies will inspire and give software architects, designers, application developers, database developers, DBAs, and data architects a complete, 360-degree perspective of programming the Oracle database. Like all-you-can-eat buffets, you can get more from your investment in the Oracle database without necessarily paying for more software (or just a very little more).



[1] Term coined by the Gartner Group to designate the integration of all middleware components as a single product.

[2] Savant term for Web services standards-based middleware that provide secure and reliable messages routing, data transformation, and connectors.

[3] Acronym for Create, Read, Update, and Delete

[4] It won’t cover the pre-Oracle 9i R2 attempt to run J2EE in the database.

[6] SQLJ Part 1 is about Java stored procedures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.36.38