Download View this document as PDF
Transcript
CHAPTER 1 Invoking Java methods as SQLJ stored procedures and functions An Introduction to Java in the Database You can enclose Java static methods in SQL wrappers and use them exactly as you would Transact-SQL stored procedures or built-in functions. This functionality: • Allows Java methods to return output parameters and result sets to the calling environment. • Allows you to take advantage of traditional SQL syntax, metadata, and permission capabilities. • Allows you to invoke SQLJ functions across databases. • Allows you to use existing Java methods as SQLJ procedures and functions on the server, on the client, and on any SQLJ-compliant, thirdparty database. • Complies with Part 1 of the standard specification. See “Standards” on page 7. Storing Java classes as datatypes With Java in the database, you can install pure Java classes in a SQL system, and then use those classes in a natural manner as datatypes in a SQL database. This capability adds a full object-oriented datatype extension mechanism to SQL, using a model that is widely understood and a language that is portable and widely available. The objects that you create and store with this facility are readily transferable to any Java-enabled environment, either in another SQL system or standalone Java environment. This capability of using Java classes in the database has two different but complementary uses: • It provides a type extension mechanism for SQL, which you can use for data that is created and processed in SQL. • It provides a persistent data capability for Java, which you can use to store data in SQL that is created and processed (mainly) in Java. Java in Adaptive Server provides a distinct advantage over traditional SQL facilities: you do not need to map the Java objects into scalar SQL datatypes or store the Java objects as untyped binary strings. Java in Adaptive Server Enterprise 3