Need to build, enhance, integrate, or manage an enterprise-class Java-based distributed database system? Tired of "toy examples"? Want to see how everything fits together in a live, breathing system? Here's your chance. Stewart Birnam shows experienced professionals all they need to create and administer robust database applications leveraging Java technologies, and running on today's key platforms-Oracle 8.x and Linux. You won't just learn a laundry list of APIs and technologies: you'll master real-world strategies for integrating them in reliable, deployable systems-and discover proven solutions for the problems that stand in your way. Understand every issue associated with building scalable, efficient, multi-tier Java code, including server configuration, brokers, client interaction, and maximizing system price/performance. Make the most of Java's database APIs; and master powerful database access techniques, from queuing to complex joins, multimedia content delivery to Oracle-specific features.Learn how to build and administer RMI servers; streamline deployment and distribution of enterprise applications; maximize code reusability; and manage your distributed application as efficiently as possible.
PrefaceQuick Start
This book covers JDBC, RMI, Swing, servlets, and command-line programs and how to tie them all together to build a system using an Oracle database and the Linux operating system. The first few chapters are mostly background information on multitiered systems. Subsequent chapters cover specific technologies and how you can reuse code used to access a database in Swing applications or servlets.
Oracle is used exclusively in all the examples that have to do with accessing a database. Examples of simple querying as well as complex joins are covered. Inserts, updates, and deletes of regular data — as well as how to store Web images as BLOBS in the database — are all shown in detail. Oracle-specific features of SQL, such as use of the CONNECT BY statement in hierarchical tables, is shown. Displaying parent-child relationships in GUIs via the Swing Jtree object is explained.
All the example code was developed on Red Hat Linux 6.1, although the code would work on any Java 1.1 capable platform, which is just about everything these days. Particular attention is given to crafting shell scripts and makefiles to make deployment and development easier. The Oracle database is version 8, running under Linux. Examples of making system calls to Unix commands, as well as building sysadmin remote monitoring tools, are also given.Introduction
Many books on Java technology exist in the marketplace. A good chunk of these are aimed at teaching the fundamentals of the language. The rest take the tack of choosing a particular API and providing an in-depth tour. Very few of these books tell you how to integrate all these APIs and technologies and actually build a deployable system. Even fewer books talk about solving very specific problems, like accessing an Oracle database. In fact, I couldn't find a single example of this, and I looked very, very hard.
Faced with having to get the job done, I ended up as many before me have: embarking on a massive research project to find and accumulate all the information and techniques I needed to build the application I wanted to build. Having done that, I decided that others might be saved the trouble I went through, by sharing the knowledge that I found hiding in so many nooks and crannies. So I wrote this book.
This book is about building systems with Java technology. Building successful real-world systems involves more than just an efficient algorithm or some clever coding tricks. It means building scalable, efficient, maintainable code, that may or may not integrate an existing system or software package, such as Oracle. With the prevalence of the Internet, your software will most certainly need to make use of the Internet and utilize established Internet protocols. In addition, you need to be able to efficiently administer, deploy, and document your system in a timely manner. Without good administration or deployment, your system is unusable and probably perceived as unstable as well.
My intent is to show you how you can solve these problems, as well as address the actual application issues, with a combination of open standards and Java technology. To illustrate these concepts, technologies, and their use, we will build a distributed database application system that uses an Oracle database.
With all the industry buzz concerning Linux recently, I set out to see if all these techniques could be applied under Linux. I'm glad to report that the Java implementations under Linux are strong and robust. Oracle now has a release of their database for Linux as well. In the last few months, all of the "gotchas" that came with deploying Java under Linux have been resolved. Java runs under Linux without any significant differences from any other Unix platform.Why a Distributed Database Application System?
Distributed computing is becoming more prevalent, thanks to the Internet and the proliferation of cheap PCs. It's no secret that the Internet is changing our lives. One interesting side effect of everyone's great interest in the Internet is the amount of computing power that now sits mostly idle, waiting for someone to click on a Web page or strike a key. Furthermore, never before has it been possible to acquire so much computer for so little price. With the network gluing all these machines together, it's now possible and important to consider distributing problems across multiple heterogeneous computers.
Database application development is by nature distributed, and almost all companies and organizations have a need for database access. A database is something you want to share. The number of people and organizations you may want to share it with may vary, but chances are the information needs to move across and be accessed by multiple systems. Even if you're implementing a two-tiered database model today, you're still distributing the work by moving the presentation layer off the server and to the client. It's an attractive idea to make the client do more work, thus enabling your server to service a greater number of requests by offloading more of its workload to the client.
Delivering a working distributed database application system calls for the integration of many APIs and technologies. You can understand all the reasons for wanting a distributed application, but implementing one requires a knowledge of networking, database programming, systems administration, GUI programming, systems programming, and Web programming — all areas in which there isn't typically a lot of skills overlap. Individuals specializing in one discipline may have almost no knowledge or experience with another. It can be difficult to pull together a team that can cover all the bases. It can be even harder to coordinate all their efforts efficiently toward the completion of a common goal.
Java has a huge collection of APIs that address all these areas and more. While other languages offer similar capabilities, I can think of no other that provides so many useful and well-documented classes as part of their core API.
Companies and organizations have an increasing need to access data from potentially distant and heterogeneous systems. E-commerce dictates the need for organizations to communicate with each other without the necessity of identical hardware or software. Java technology, with its strength in network programming and cross-platform "write once run anywhere" capabilities, is uniquely suited to address this problem. In addition, scientific and technical computing can also benefit from this technology by enabling collaboration all over the world.
Today's market requires flexible systems to respond to swiftly changing needs of the organization and consumers. The pace of technology and systems today is astonishing. It is fairly evident that in order to maintain any kind of production environment you will always be integrating new technology with old, and new systems with existing systems. In addition, not only may your systems be changing rapidly due to technical reasons, but you may also be changing the way that you do business just as rapidly. Your systems need to be designed in such a way to accommodate this. Object-oriented programming and Java technologies can help you build systems toward this goal.
You may still have to leverage the existing systems and resources. Many companies and organizations today still require expensive legacy systems, or have legacy applications in place for some departments because of a vertical application and/or significant training investment. Often there are also political factors as to why one technology is adopted over another, and those technologies may change from department to department. Spreadsheets, e-mail, text files, and databases all abound as individuals in the organization build their own systems based on their needs and skill levels.
Typically in this environment, you may have programmers scattered across the organization, coding in a variety of languages on multiple platforms. In an early effort to get information to flow from one division to another, several patchwork systems may have evolved. This kept things moving, but as the needs of the organization changed, it became harder and harder to implement new systems for fear of breaking the old ones. Not to mention that not everyone may be comfortable with dropping his or her system in favor of someone else's, and potentially losing the control they may have had.
A key focus of this book is the belief that systems need to be able to react swiftly to the changing needs of the organization. Their architecture needs to be designed to reflect this. Many organizations — including startups, nonprofits, media, scientific/engineering environments, and others — may also have the additional constraint of limited budget and/or nontraditional business models that make out-of-the-box solutions impossible or prohibitively expensive. Moreover, it may be necessary to integrate many types of data storage methods in an effort to bring the departments together into a centralized information base.Can Java Technology Help Me Build Systems?
This book is an answer to that question, and sets out to design a new system that maintains flexibility while respecting the needs of various users. We accomplish this by building and designing our business applications and systems with Java technology using a distributed computing model. Java's strength as a network programming language, its cross-platform nature, and ability to interface natively with many vendor databases make the entire thing possible. Furthermore, the almost daily addition of more APIs for the Java environment makes its use more attractive than ever. Literally every facet of computing is covered, from XML to 3D, sound to Jini. There has never been a more widely used and supported set of APIs. Not to mention that most of these APIs have accessible source.Intended Audience
Are you:
thinking of designing a distributed database system?
in charge of an IS/IT department?
a software developer looking to get an insight into some new technologies in order to help solve a particular problem?
a budding programmer who's tired of poring over simple examples, and wants to see how everything integrates into a single, breathing system?
If any one of these is you, then this book will help.
If you're a software developer, this book will serve as a guide in building distributed systems. If you're a systems administrator, it will help you understand what the administration and maintenance issues for systems like these are. If you're an IT/IS manager, you can get a good understanding of the requirements in these kinds of systems, that will help you develop strategies and staffing/budget requirements for your projects.
Whichever focus you have, this book will help you understand how all these complex issues blend together to build a system. Even if you decide not to do the core development yourself, but rather integrate turnkey solutions instead, you will be in a better position to evaluate those systems and perhaps even write the "glue" to hold them together after reading this book.Organization of This Book
In the beginning of each chapter you will find a quick outline in case you want to skip through, or quickly find some code snippet or piece of wisdom. Several chapters will have sections devoted to technology overviews, programming, administration, and support and deployment where relevant. In this way you will be able to safely skim through sections that may not be critical to you.
For programmers, rather than take you on a tour of the various API specifications, I'm going to assume you're already familiar with the core API. That is, you've looked at other books in this series, have tried out some of the examples, but are still wondering how it all fits together. To that end you'll see throughout this book how the various Java APIs are brought together to create something real. In this respect alone, you may find this book valuable even if you don't intend to implement a complete system yourself. Understanding the fundamentals of how all the various components fit together will aid you tremendously in your evaluation of third-party solutions and/or development libraries.
In addition, I'll show you how to integrate the software you build with existing, well-known open source and commercial systems. By the end of this book, you should have all the information you need to decide what pieces of the system you'll have to build and what pieces you can integrate. To get the most out of this book, you should have some familiarity with:
Relational databases
SQL (Structured Query Language — a nonprocedural language used to extract information out of databases)
JDBC (Java Database Connectivity — part of the 1.1 and greater core API)
HTTP
NFS (Network File System — commonly used file sharing scheme under Unix)
FTP
Samba (An SMB system that runs on Unix servers, making it possible to share files to Win32 machines)
SMTP (Simple Mail Transport Protocol — the underlying protocol for Internet e-mail)The Road Ahead
In Chapter 1, we'll describe a distributed database solution implemented entirely in Java. It gives a high-level view of the server configuration, how the broker works, and how the various clients interact with the system. It focuses on hardware independence, and provides guidelines for determining the price/performance ratio of your system.
Chapter 2 details the building of a database API to abstract the nuts and bolts of the database for the application programmer. We'll deal with ways you can encapsulate your SQL into an API.
Chapter 3 deals with the construction of an RMI server, along with tips on how to administer it.
Chapter 4 starts the discussion of client development by building a Swing application using the database API. General issues of using remote objects and Swing are discussed, with special attention to exception handling. Examples are given specific to populating GUI components with data from the database, like Lists, Tables, Trees, and ComboBoxes.
Chapter 5 gives us a taste of how nice it is to be able to reuse your software by delivering access to the same database API via servlets. We also give a brief tour of the Apache JServ and Java Web Server from an administration and development perspective.
Chapter 6 lets us now gorge ourselves in reusability by building a command-line client to provide an even easier way for script programmers or Web developers to access your database API.
Chapter 7 shows you how to make your software distribution simple, and save you from walking to each machine and installing it. This is accomplished by some very well-known services (HTTP, FTP, NFS, and Samba), and some clever systems architecture and scripts.
Chapter 8 gives a how-to on reading and writing BLOBS (Binary Large Objects) to the database. Special attention is given to delivering images and other multimedia content from BLOBs to servlets and applications.
Chapter 9 illustrates how to build your own monitoring tools to help your administrators and support staff, as well as how to make system calls accessible via RMI.Running the Example Code
All the examples in this book were developed and tested under Red H...