White Paper
Index
Opening new doors for IT development
Why Java?
Java for logic in the database
Java for object data types
Java and the object-relational database
Java concerns
Server-based Java and the client application
Conclusion
Opening new doors for IT development
As part of the Sybase Adaptive Component Architecture, Sybase is developing a Java™ architecture for its relational Adaptive Server database. This will bring a new level of sophistication and openness to server-based programming, and a new dimension of flexibility to application development and deployment. At the same time, it will provide an open, object-relational database management system.
The single goal of the Sybase Java initiative is to solve problems that currently face information technology (IT) organizations.
Right now, the landscape of IT application development is severely fragmented. On one hand, application logic outside the server is in the form of 3GL's such as C/C++ and Java, or 4GL's such as PowerBuilder and Visual Basic. On the other hand, logic inside the DBMS is in the form of SQL-based stored procedures, and never the twain shall meet.
The Sybase Java initiative takes the Java promise of write once, run anywhere, and extends it to a new platform—the DBMS. In so doing, it provides application developers with what they need to increase productivity—it removes the barrier between client-side and server-side programming, and does so in a way that feels natural to both SQL and Java programmers.
Benefits
The Sybase Java initiative will open new doors for enterprise application development.
A full-featured programming language for the DBMS Application logic (in the form of Java classes) will run in Adaptive Server in a secure fashion. A Java virtual machine (VM) and an internal JDBC™ interface are being built into Adaptive Server to make this happen. In this way, Sybase is bringing a full-featured yet secure programming language into the server, overcoming the programming limitations of SQL-based stored procedures.
Object data types Java objects can be stored as values in a relational table. This provides the support for rich data types that other object-relational databases have aimed for, but by using Java it does so in an open, non-proprietary fashion.
A consistent programming model For the first time, application components can be moved between clients or middle-tier servers and the DBMS. Developers have a single consistent programming model for all tiers.
A natural implementation Sybase is committed to a natural implementation: Java objects and syntax work as you expect them to work, server schema function in an expected manner, even when interacting with Java objects.
A commitment to openness and standards
Sybase aims to succeed by being the best company for IT to work with, not by providing proprietary solutions to IT problems.
The Java relational architecture removes barriers to application development productivity, but proprietary implementations of new technologies can create other barriers.
To further promote the open development environment Sybase believes IT organizations need, Sybase is working with JavaSoft, the ANSI SQL standards committee, and the JSQL consortium to develop standards for running Java in the DBMS.
Sybase is committed to helping IT departments deal with the exploding complexity of enterprise information systems and applications. We believe that Java provides a tool to accomplish this goal.
Java is the language of choice for the next generation of IT applications because it promises to greatly improve the productivity of application development efforts. Sybase believes that Java also holds the key to improving the productivity of server-based development and extending the scope of database servers.
Sybase believes that Java is also the language of choice for database server-based development, for several reasons:
Because of its momentum in application development To remove barriers between client and server development, the same language should be in use on both platforms.
Because of its built-in security features For a language to run inside a critical platform such as a DBMS, there must be built-in protection for the platform itself. Java provides such protection.
Because of its object-oriented features For a language to be used as the basis for object data types, it must be highly object oriented. Java is designed as an object-oriented language from the bottom up.
Sybase sees two roles for Java in the database:
A language for server-based logic, as successor to SQL-based stored procedures.
A means of storing object data types in the database.
The next two sections discuss these roles in turn.
Java for logic in the database
Today's data servers use SQL to perform two tasks; data access and server-based logic. While SQL continues to be an excellent language for data manipulation and definition, the stored procedure extensions to SQL that allow server-based logic show some clear weaknesses.
SQL stored procedures are limited by the lack of development tools, the inability to move stored procedures outside the server, and the lack of many features found in modern application programming languages such as external libraries, encapsulation and other aspects of object orientation, and the ability to create components.
Java provides a natural solution to the limitations of stored procedures for encoding logic in a server. SQL continues to be the natural language for data access and modification.
Installing classes into the server
Java logic is written in the form of classes. To use Java in the server, Adaptive Server will provide the ability to install a Java class into the server. The class is compiled into bytecode (ready for execution by the VM) outside the server. Once installed it can be run and also debugged from inside the server.
Accessing SQL from Java with JDBC
To implement Java logic in the database, there is a need for Java interface to SQL. Just as SQL data manipulation and definition statements can be accessed from stored procedures, so they must be accessible from Java methods.
On the client side, JDBC provides an application programming interface (API) for including SQL in Java methods. JDBC is a Java Enterprise API for executing SQL statements and was introduced in the Java SDK 1.1.0.
To meet the goal of removing barriers to application development and deployment, JDBC must also provide the interface for accessing SQL from Java methods inside the database, and so an internal JDBC interface for Adaptive Server is a key part of the Sybase Java initiative.
Facilitating JDBC development
Like ODBC, JDBC is a low-level database interface. Just as many RAD tools have built their own more usable interfaces on top of ODBC, so there is a need for interfaces on top of JDBC if developers are to be productive.
As the Sybase implementation installs compiled Java classes (bytecode) into the DBMS, any of the higher-level tools and methods that generate Java and JDBC code are automatically supported.
For example:
JSQL JSQL is an alternative method of including SQL calls in Java code, which is managed by a consortium including IBM, Oracle, Sybase, and Tandem.
JSQL provides an Embedded SQL capability for JDBC. JSQL code is simpler to write in some cases than JDBC, and for database administrators has the advantage of being closer to the way in which SQL-based stored procedures are written.
JSQL code is preprocessed into JDBC calls before compilation. Adaptive Server users will be able to write in JSQL if they wish, and install the preprocessed code into the server.
RAD Tools RAD tools for Java, such as Sybase PowerJ, provide Java classes built on top of JDBC to provide a more useable interface for developers. Such classes can be installed into the server for use.
JavaBeans JavaBeans are components : collections of Java classes with a well-defined interface. JavaBeans can be installed into the server in the same way as any other set of classes.
The Sybase Adaptive Component Architecture recognizes that component-based application development has become the major way to build enterprise database applications, and the principal method of accelerating software delivery by reusing code.
The ability to use JavaBeans components across tiers, including within the database, will bring the advantages of Java to enterprise database applications. Adaptive Server will support JavaBeans and Enterprise JavaBeans running in the server.
Re-usability: the key to Java support
With a VM to execute Java methods, and an internal JDBC interface, the same Java object (written directly using JDBC, using a RAD tool such as PowerJ, or using JSQL) can be used both outside the server and inside the server.
Sybase believes that for IT to get the most out of the Java productivity boom, it is crucial that Java classes not have to be specially written for the server. Unlike some other approaches, the Sybase implementation is built around this key feature.
In addition to building application logic into the server, Java provides a solution to other limitations of today's relational databases. In particular, it provides a means of extending the range of data types to include richer and more versatile options.
Once a Java class is installed into Adaptive Server, it is available for use as a column data type. Each row of the column becomes a Java object.
A simple example is a Java class to hold addresses. You could create and install into Adaptive Server an Address class that holds street, city, and zip code information. You could then create a column with the Address data type, and for each row of the database insert a new address. The different address fields can be accessed separately in queries.
The use of even a class as simple as Address provides several benefits to database users:
By encapsulating the notion of an address, it is easier to ensure that consistent address information is held in different tables (say in a customer table, an employee table, a supplier table, and so on) throughout a database.
Logic can be included in the class methods. For example, it would be possible to insert only the street and zip code, and yet retrieve a computed city using a method that infers the city from the zip code. To the external user, there is no difference between a city that is stored in the database explicitly, and one that is computed from the zip code.
You can use inheritance on classes on which a column is based to include methods that apply to only some of the rows in the column. For example, you could create classes US_Address and CanadianAddress , inherited from Address . These classes could contain checks to ensure that addresses contained valid zip codes (US) and postal codes (Canada). You can insert an Address object, a US_Address object or a CanadianAddress object into a column of type Address.
The ability to store Java objects in relational databases is an important new capability for enterprise applications. It provides a new level of deployment flexibility and code reuse for IT organizations.
Accessing Java objects from SQL
While JDBC provides an industry standard for accessing SQL from Java, there is no corresponding standard for accessing Java objects from within SQL. Sybase has developed such an interface, and is working with standards bodies to establish a standard.
The guiding principle for Sybase has been to develop a "no-surprises" interface, so that Java objects work as you expect them to work within SQL statements.
Examples
The following statement inserts a new row into the table:
INSERT INTO employees ( id, name, Address )
VALUES ( 1235,
'Jane Doe',
new Address ('6475 Christie Avenue', '94608' )
)
The following statement inserts a new row into the table, but instead of using the Address class that is the data type of the column, it uses the class CanadianAddress , which is inherited from the Address class.
INSERT INTO employees ( id, name, Address )
VALUES ( 1235,
'John Smith',
new CanadianAddress ('415 Phillip Street', 'N2L 3X2' )
)
The following query shows how to retrieve the name and the street field or method of the Address column, which has a Java class data type:
SELECT name, Address.street
FROM employees
WHERE id = 1234
Java objects can also be used as part of other clauses in queries. For example, the following query returns the name of each employee who lives on a particular street:
SELECT name
FROM employees
WHERE Address.street = 'Christie Avenue'
Java and the object-relational database
The object-relational database is a name for a range of attempts to satisfy customer needs that cannot be met using only the data types available to traditional relational databases.
One need is for user-defined data types that may be specific to each organization. Sybase is using Java classes to address this need.
Another need is for a relatively small number of specialty data types such as text, geo-spatial, time series, and multi-media data. These specialty data types have their own indexing and management requirements, and Sybase is addressing the need through the component integration layer build into Adaptive Server.
With Java and the built-in component integration layer, Sybase is providing an object-relational database that is tuned to meeting customer needs.
Security and performance are always paramount concerns for database administrators and enterprise IT organizations. The security and performance features of Java are also continuing subject of discussion throughout the Java community.
Addressing security issues
Organizations entrust critical information to relational databases, and so security and integrity are of paramount concern. As an enterprise database company, Sybase understands these concerns, and they are at the core of the Java architecture. For example:
The only Java classes that can be used in a server are those installed by the database administrator.
The administrator can restrict which methods and fields of a class are available from SQL.
The Adaptive Server Java VM does not support tasks that may pose a security problem in a data server. File I/O functionality is not supported, for example.
Java itself is designed with security in mind. It is ideally suited as a language to run inside a security-sensitive environment such as a DBMS.
Addressing performance issues
While it is true that the performance of Java has been a popular topic of discussion, Sybase shares the confidence of many that Java performance concerns will recede over the coming year. Analyst Stan Dolberg of Forrester Research commented recently; that "I think we are within six months of the performance issue being a yawn". #
Great strides continue to be made by compiler developers, including those in the Powersoft tools division of Sybase. Adaptive Server users can take advantage of these developments, as Java classes are installed into the server in compiled form.
In addition, Adaptive Server gives the database administrator control over how a class stores its objects, allowing the kind of tuning administrators expect for their DBMS.
Server-based Java and the client application
Sybase is committed to solutions that preserve the value of investments made by existing customers. Adaptive Server is designed to allow current systems to run unmodified while accessing new features as and when required.
Java features of Adaptive Server are available to existing non-Java client applications using standard ODBC or Open Client interfaces to the server. Java client applications can take advantage of additional capabilities.
Support for all client applications Java support for non-Java clients employs an internal mapping between Java and SQL. The client application communicates with the server using a standard interface, such as Sybase Open Client or ODBC. The fields of Java objects in tables can be accessed and used within SQL statements, and Java methods executed in the same manner as SQL-based stored procedures. Only SQL data types are made available to the client application. Support for Java client applications Java client applications will be able to connect to Adaptive Server through a JDBC interface. In addition to the capabilities available to non-Java applications, this will permit the exchange of Java objects between a Java client application and Adaptive Server. When a Java object is requested from the server, it is sent in serialized form to the client application, where it is sent to the client-side virtual machine for execution. As has been stressed throughout this paper, the Java architecture for Adaptive Server is such that, unlike in some other implementations, classes do not have to be specifically written for use in the server. A class can be used in a client application or mid-tier application server, and then moved into the DBMS without modification to repartition the application logic. For example, if the city method of an Address class inferred a city name from a stored zip code, the method could be invoked in either the client or the server.
Sybase aims to succeed by meeting the needs of IT departments, and the Java strategy for Adaptive Server accomplishes this by removing artificial barriers that make the complex tasks of IT departments even more difficult. Java is the new language of choice for application development, and the associated technologies of JavaBeans and Enterprise JavaBeans are important object models for building Java applications. Meanwhile, relational databases are the databases of choice for businesses. The ability to store and run Java objects in relational databases opens new doors for enterprise application developers, and will bring the advantages of Java to enterprise database applications.