Académique Documents
Professionnel Documents
Culture Documents
JPub generates Java source code that makes it easy for you to represent
Oracle Object types and PL/SQL packages in your Java programs. JPub is
documented in the _Oracle 9i JPublisher User's Guide_. Some of the comments
in this README file presume that you have seen the JPub documentation.
In the future, JPub may be decoupled from SQLJ, in that JPub would generate
.java code that does not depend on SQLJ runtime. JPub communicates with the
database via JDBC. To run JPub, you must also install a JDBC driver. If you
are using Oracle objects, an Oracle 9.2.0 JDBC driver is recommended, and
an Oracle 8.1.x JDBC driver is required.
By default, JPub communicates with the Oracle database using the Oracle
JDBC OCI driver, but you may select another driver, such as the Oracle
"thin" driver, by setting the -url command-line parameter.
Let ORACLE_HOME be the location into which your Oracle products have been
installed.
The installation process will create a script file (a shell script on Unix
platforms, and a .bat script on Windows platforms) that directly includes
references to the Java JRE, the JDBC driver, and the SQLJ translator that
has been installed. You should be able to just invoke this script by typing
jpub
If you have downloaded JPublisher from the Oracle website as part of the
SQLJ product, then the "jpub" script will not have been automatically
created and customized for you. In this case you should perform the steps
outlined below.
java oracle.jpub.Doit
followed by zero or more command-line arguments. The command above has the
same effect as the "jpub" command mentioned in Section 1.1, except that,
with the command above, JPublisher picks up the CLASSPATH setting in your
environment, while in the Section 1.1 case, the CLASSPATH variable picked
by JPublisher is pre-defined during installation.
First, download the webservice callout utility for 10g from the OTN website
below.
http://otn.oracle.com/tech/webservices/database.html
ORACLE_HOME/sqlj/lib
Third, load the utl_dbws_jserver. jar file into the SYS schema or into the
schema where the webservice client will be invoked. For instance, to load
that jar file to SYS, use the loadjava command below.
Question: Why can't I write Java classes by hand for my object types and
packages?
A Java class that represents an Oracle object type in a JDBC program must
implement the oracle.sql.ORAData interface or the java.sql.SqlData
interface. A Java class that represents an Oracle object type in a SQLJ
program must also name the object type in a declaration within the class of
the form
Code generated by JPub handles these tasks for you. In addition, for both
object types and PL/SQL packages, JPub generates code to handle the details
of argument passing and method invocation when server methods are invoked.
If you edit the class generated by JPub, and at some time in the future you
need to run JPub again to regenerate the class, you will have to save the
changes you made and reinsert them by hand. It is probably more convenient
for you use subclasses that extend the classes generated by JPub. When you
do this, you must tell JPub about the subclass you want to use with the
-input file syntax
As of version 9.2, JPub even generates a first version of this subclass for
you - all you need to do is edit the generated file. See your JPub
documentation for more information on this feature.
Yes. JPub, the Oracle JDBC drivers, and Oracle SQLJ support your choice of
the oracle.sql.ORAData interface or the java.sql.SqlData interface. By
default, JPub generates to the oracle.sql.ORAData interface. You request
java.sql.SqlData by specifying
-usertypes=oracle
-compatible=CustomDatum
Yes, by specifying it on the command line after the -props option. Options
are processed from left to right in the order in which they appear on the
command line. Options in the -props file are processed when the -props
option is encountered on the command line.
If the options -input, -sql, and -types are all absent, all types and
packages in the user's schema will be translated.
The encoding option specifies the character encoding to use for the input
file generated by JPub, and for the .sqlj and .java files generated by
JPub. The -encoding setting does not affect how the command line or the
-props file is read.
Question: I'm happy with the way JPub translates my object types to Java,
but I also want to use object types in C programs. How can I accomplish
this?
Another Oracle utility, the Object Type Translator (OTT), translates object
types to C.
3. NEW FEATURES IN JPUB
The following changes were made to JPub between verstion 10.1.0.0.0 and
10.1.0.2.0.
Using the "-proxywsdl" option, JPublisher can generate and load the
webservice client and the corresponding PL/SQL call specification into the
database, so that one can invoke the database webservice from the database.
This functionality is also called webservices callout.
The "-plsqlfile" option specifies the PL/SQL wrapper file generated during
publishing PL/SQL stored procedure. Now the "-plsqlfile" can take second
argument, a file that holds the SQL script file to drop the generated
PL/SQL wrapper, for instance,
-plsqlfile=my_wrapper.sql,my_dropper.sql
With the setting -sqlj, JPublisher will use all the options following that
"-sqlj" setting as SQLJ options to translate .sqlj programs generated into
.java programs.
At the end of the JPublisher command line, one can specifies .sqlj or .java
programs to be translated and compiled along with JPublisher-generated
code. For instance,
The following changes were made to JPub between verstion 9.2.3.0.0 and
10.1.0.0.0.
JPublisher can publish SQL queries and DML statements via the option
"-sqlstatement". SQL queries and DMLs can be published as methods in a
generated Java class.
Using the "-java" option, given a Java class in the server (database),
JPublisher can generate a correpsonding client-side class which invokes the
static methods in that Java class.
Using the "-proxyclasses" option, JPublisher can create PL/SQL proxy for
Java classes. A typical scenario for the "-proxyclasses" functionality is
WebServices call-outs, where the web service calls originate from the
database.
Using the "-style" option, JPublisher can map an argument type into another
type in the generated user subclass. As an example, JPublisher can map a
returned ReultSet into an array of Java Beans, a XML document, or a
WebRowSet.
Using the "-generatebean" option, JPublisher can make sure the generated
Java classes for SQL types are Java beans.
The following changes were made to JPub between verstion 9.0.2.1.0 and
9.2.3.0.0.
JPublisher now can generate interfaces along with classes. For instance,
the command "jpub -sql=<sqlType>:<javaClass>#<javaInterface>:<myClass>"
generates, for a SQL type (<sqlType>), a java class (<javaClass>), a java
interface (<javaInterface>), and a user Java class (<myClass>), where
<javaInterface> defines the interface of <javaClass>. The generated
interface contains the public methods in the generated class, typically
those accessors methods.
The following changes were made to JPub between version 9.0.1.0.0 and
version 9.2.0.1.0.
JPublisher now supports virtually all of the types that can be used by the
Oracle JDBC driver. Additionally, JPublisher facilitates the use of PL/SQL
types in stored procedure and object method signatures through PL/SQL
conversion support.
- NCHAR types
- TIMESTAMP types
Native PL/SQL types can now be more easily accessed by JPublisher code
through the automatic generation of PL/SQL wrapper functions and procedures
in conjunction with the following mechanisms:
- Generated Java wrappers for SQL object types can be made serializable
(new option -serializable)
- JPub can create toString() methods that report the object value (new
option -tostring)
The following changes were made to JPub between version 8.1.7.0.0 and
version 9.0.1.0.0.
- JPublisher now only generates SQLJ code for an Object type if that type
contains methods. Otherwise it will generate Java code by default (unless
you use the option setting
-methods=always).
- The new JPublisher option -access permits control over the access
modifier of JPublisher-generated methods, and the new option
-context permits control over the class that is used for SQLJ connection
context (sqlj.runtime.ref.DefaultContext by default), and also whether
indiviual Java wrapper classes declare their own individual SQLJ context
types or not.
The following changes were made to JPub between version 8.1.6.0.0 and
version 8.1.7.0.0.
- The following fields have been made protected in JPub-generated code for
SQL object types. This provides for additional capabilites in user-written
subclasses of the JPub-generated class.
- _ctx - the SQLJ connection context object
- _struct - the mutable struct object with the data in original SQL format
- The Java keyword "null" takes on special significance when used as the
Java name for mapping attributes or methods.
- no method will be generated when a SQL method is mapped to null
- no getter/setter methods will be generated when a SQL attribute is mapped
to null
1757898 When you use JPublisher to generate Java code for a SQL Object type
hierarchy where some classes add method
definitions while others do not, JPublisher will now generate all classes
into .sqlj files (unless the option
-methods=false was specified). This ensures that the generated files are
compatible with one another.
n/a JPub now supports the following SQL argument types which are also
supported by JDBC 9.2 and/or SQLJ:
- OPAQUE types
- SQLJ object types
- TIMESTAMP types
- NCHAR
- NCLOB
- NVARCHAR2
n/a JPub can now support the PL/SQL argument types, either automatically,
or through a user-provided type conversion between the PL/SQL type and a
corresponding SQL type.
- BOOLEAN
- record types
- index-by tables
1534649 JPub did not generate code for PL/SQL packages if no package body
existed. This happened, for example, if the package
header was created in advance of the implementation and then JPublisher was
run to generate a .sqlj wrapper class for this package.
1364448 JPub did not read the last line of the inputfile when that line was
not terminated by LF or by CR/LF.
then you are using JPublisher against an Oracle 9.2 database that is not
Java enabled. In general you can ignore this message, unless you want to
use SQL opaque types or SQLJ object type.
You can get rid of this message by installing the package SQLJUTL into the
SYS schema. This package is defined in the following SQL script file.
[Oracle Home]/sqlj/lib/sqljutl.sql
n/a The Java code that JPublisher generates to represent strongly typed
instances of REFs permits you to create Java Refs using the empty
constructor. However, calling getValue() or setValue() on such an instance
results in a NullPointerException. You must always obtain a Java Ref
instance from the database (or as an attribute of a database object).
JPub reports most, but not all, errors in the -input file to the user. A
few errors in the -input file are not reported by JPub. These errors are
listed below:
* If the user requests the same Java class name for two different object
types, the second class will silently overwrite the first. For example, if
the -input file contains
the file person.java will be created for type PERSON1, and then will be
overwritten for type PERSON2.
* If the user requests the same attribute name for two different object
attributes, get and set methods will be generated for both attributes
without issuing a warning message. Whether or not the generated class is
legal in Java depends on whether the two get methods with the same name and
the two set methods with the same name have different argument types so
that they may be overloaded.