Which translator is used by java




















You can also receive information about the profile customizer or Java compiler, requesting help through the -P and -C prefixes as in the following examples. As with the -help flag, no translation is performed if you request customizer or compiler help. Enable it by typing only the desired flag setting. The most basic level of help is achieved by specifying the -help setting. This provides the following:. This setting provides a complete list of SQLJ option information, including the following for each option:.

It is often useful to include other option settings on the command line with a -help-long option, especially with complex options such as -warn or combinations of options, so that you can see what option settings resulted from your actions. The -help-long mode displays current settings of all options. This setting provides a synopsis of the command-line abbreviations supported for compatibility with the loadjava utility.

No input-file translation is performed when you use the -version option, even if you include file names and other options on the command line. SQLJ assumes that you either want to run the translator or you want version information, but not both. Properties files and anything else you type on the command line are ignored. Enable it by typing only the flag name. This includes capturing and echoing the name of the JVM that would be launched to execute the SQLJ translator and echoing the full class name of the translator.

This does not include settings from properties files. The -encoding option specifies the encoding to be applied to. If setting sqlj. When this option is specified, it is also passed to the Java compiler unless the -compiler-encoding-flag is off , which uses it to specify encoding for. Whether profiles are generated as. Whenever a directory is specified, the output files are generated under this directory according to the package name, if applicable.

For example, if you have source files in package a. You can also use standard syntax such as a period for the current directory or two periods to go up a level the second example immediately below will go up a level, then back down to a parallel directory called paralleldir :. If the -d option is empty or not specified, then. The -dir option specifies the root directory for. If the -dir option is not specified, then files are generated under the same directory as the original. If you specifically want the output directory to be the same as your.

You can use the following options for the database connection for online semantics-checking:. There is no requirement for the SQLJ translator to connect to the same database or schema as the application does at runtime.

The connection information in application source code can be independent of the connection information in the SQLJ options. In fact, the deployment environment might be unavailable during development and testing. Simple semantics-checking not involving a database connection is referred to as offline checking. The more thorough semantics-checking requiring a connection is referred to as online checking.

Online checking offers one of the prime advantages of the SQLJ strong-typing paradigm--type incompatibilities that would normally result in runtime SQL exceptions are caught during translation, before users ever run the application.

The -user option enables online semantics-checking and specifies the user name schema name for the exemplar schema, which is the sample database schema that you provide to the translator for it to use in performing the checking. You can also use the -user option to specify the password and URL, as opposed to using the -password and -url options separately.

Note that there is no other flag to enable or disable online semantics-checking; SQLJ enables it or disables it according to the presence or absence of the -user option. Discussion of the -user option is split into two categories effect of -user when you are employing the default connection context class only; and 2 effect of -user when you are employing nondefault or multiple connection context classes. Nondefault connection context classes are discussed in "Connection Contexts". General discussion of connection considerations, such as when to use multiple instances of the DefaultContext class and when to declare additional connection context classes, is in "Connection Considerations".

When you are using only the default connection or other instances of the DefaultContext class, such a setting will apply to all your SQLJ executable statements. This example results in online checking against the scott schema. Otherwise the URL can be specified through the -url option, and the password can be specified interactively or through the -password option. You can disable online semantics-checking by setting the -user option to an empty string:.

Again, when you are using only the default connection or other instances of the DefaultContext class, this will apply to all your SQLJ executable statements. Disabling online semantics-checking is useful, for example, if you have online checking enabled in a properties file but want to override that on the command line, or have it enabled in the default properties file but want to override that in a user-specified properties file specified using the -props option.

There is also a special user name, URL. If you declare and use additional connection context classes in your application, then you can specify -user settings for the testing of SQLJ executable statements that use instances of those classes. Specify a user name for online checking against a particular connection context class CtxClass , for example as follows:.

This results in online checking against the scott schema for any of your SQLJ executable statements that specify a connection context instance of the class CtxClass. As with the default connection context class, you can also specify the password or URL in your -user setting for a particular connection context class, as in the following example:.

The CtxClass connection context class must be declared in your source code or previously compiled into a. See "Connection Contexts" for more information. Employ the -user option separately for each connection context class for which you want to enable online checking and set a user name; these settings have no influence on each other:.

When you are using multiple connection context classes in your application, a -user setting that does not specify a class will apply to the DefaultContext class as well as to all classes for which you do not otherwise specify a -user setting. Presumably, though, you will specify a -user setting for each connection context class, given that different connection context classes are typically intended for use with different sets of SQL objects.

Consider a situation where you have declared connection context classes CtxClass1 , CtxClass2 , and CtxClass3 and you set -user as follows:. Any statement in your application that uses an instance of CtxClass2 will be checked against the scott schema.

Any statement that uses an instance of DefaultContext , CtxClass1 , or CtxClass3 will be checked against the bill schema. In addition, once you enable online checking by setting the -user option, you can disable online checking for a particular connection context by setting the -user option again with an empty user name for that connection context. For example, consider the following setting:.

This disables online semantics-checking for any SQLJ executable statements that specify a connection object that is an instance of CtxClass2. To disable online semantics-checking for the default connection context class and any other connection context classes for which you do not specify a user name:. Be aware of the difference in format between specifying user, password, and URL in the -user option and specifying them in the -url option. The -password option specifies the user password for the database connection for online semantics-checking.

For the -password setting to be meaningful, the -user option must also be set. You can also specify the password as part of the -user option setting. Do not use the -password option for a connection context class if you have already set its password in the -user option, which takes precedence.

For the most part, functionality of the -password option parallels that of the -user option. That is, if your application uses only the default connection or other instances of DefaultContext , the following will set the password for the schema to be used in checking all of your SQLJ statements:. If you declare and use additional connection context classes, CtxClass1 for example, then you will presumably employ the -user option to specify additional exemplar schemas to use in testing statements that use those connection context classes.

Similarly, use the -password option to specify passwords for those schemas, as in the following example:. A connection context class without a password setting, either through the -password setting or the -user setting, uses the password setting for the default connection context class.

If you set no password for the default connection context class, then SQLJ prompts you interactively for that password. If you also set no password for a user-defined connection context class, then SQLJ prompts you interactively for that password as well. An exception to this discussion is where user name URL. In this case, user name and password are determined from the string specified in the -url setting, and any setting of the -password option is ignored. You can specifically set an empty password to override other settings of the -password option, such as in a properties file, and be prompted interactively.

You can do this for the DefaultContext class or any particular connection context class, as in the following examples:. The Oracle9 i database, however, does not permit an empty password.

The -url option specifies a URL for establishing a database connection for online semantics-checking. You can also specify the URL as part of the -user option setting. Do not use the -url option for a connection context class if you have already set its URL in the -user option, which takes precedence. For the most part, functionality of the -url option parallels that of the -user option.

That is, if your application uses only the default connection or other instances of DefaultContext , the following example would set the URL to use for the connection for checking all your SQLJ statements:.

If you do not begin a URL setting with jdbc: then the setting is assumed to be of the form host : port : sid and by default is automatically prefixed with the following:. A -url setting of localhostorcl would result in the following URL:. You can remove or alter this default prefix with the -default-url-prefix option. You can specify the user and password in the -url setting, instead of in the -user and -password settings. In such a case, set -user to URL.

If you declare and use additional connection context classes, CtxClass1 for example, you will presumably specify additional exemplar schemas to use in testing statements that use those connection context classes.

You can use the -url option to specify URLs for those schemas, as in the following example:. Any connection context class without a URL setting, either through the -url setting or the -user setting, uses the URL setting for the default connection context class, presuming a URL has been set for the default context class. In the -user option, they precede the URL. Use the -default-url-prefix option to alter or remove the default prefix.

The following is the default prefix for any URL setting you specify that does not already start with jdbc:. This allows you to use a shorthand in specifying a URL setting, either in the -user option or the -url option--it is permissible to specify only the host, port, and SID of the database. As an example, presume you set a URL as follows:. If you specify a full URL that starts with jdbc: , then the default prefix will not be used, such as in the following example:. However, if you want your URL settings to default to the OCI driver, for example, instead of the Thin driver, then set the default prefix as follows:.

If you do not want any prefix, then set the -default-url-prefix option to an empty string, as follows:. Specify a driver class or comma-delimited list of classes. The following options specify what types of conditions SQLJ should monitor, whether to generate real-time error and status messages, and whether to include "cause" and "action" information with translator error messages:.

The following options enable line-mapping from the generated Java. Use -jdblinemap in conjunction with the Sun Microsystems jdb debugger; otherwise use -linemap. There are various warnings and informational messages that the SQLJ translator can display as dictated by conditions it encounters during the translation. The -warn option consists of a set of flags that specify which of those warnings and messages should be displayed in other words, which conditions should be monitored and which should be ignored.

Table documents the conditions that can be tested, what the true and false flag values are for each condition, what a true flag value means, and which value is the default. Test for requirement of subtypes of declared object type in an inheritance hierarchy--Enable cast to receive warnings when usage of SQL object types in a SQL inheritance hierarchy requires that subtypes of a declared type must be passed at runtime. Data precision test--Enable precision to receive warnings if there was a possible loss of precision when moving values from database columns to Java host variables.

Conversion loss test for nullable data--Enable nulls to receive warnings if there was possible conversion loss when moving nullable columns or nullable Java types from database columns to Java host variables. Portability test--Enable portable to check SQLJ clauses for portability and receive warnings if there are non-portable clauses.

Where non-portable refers to the use of extensions to the SQLJ standard, such as vendor-specific types or features.

Strict matching test for named iterators--Enable strict to instruct SQLJ to require that the number of columns selected from the database must equal the number of columns in the named iterator being populated. A warning is issued for any column in the database cursor for which there is no corresponding column in the iterator. The nostrict setting allows more but not fewer columns in the database cursor; unmatched columns are ignored.

Translation-time informational messages--Enable verbose to provide additional informational messages about the translation process such as what database connections were made for online checking.

It does not enable a particular test but enables output of general informational messages about the semantics-checking. The -status flag provides real-time informational messages about all aspects of SQLJ translation--translation, semantics-checking, compilation, and profile customization if applicable.

You can use it to enable or disable all flags, or to serve as an initialization to make sure all flags are off before you turn selected flags on, or vice versa. Separate settings of the -warn option in properties files and on the command line are not cumulative. Only the last setting is processed. The cast, precision, nullability, and strictness tests are part of online semantics-checking and require a database connection. The -status flag instructs SQLJ to output additional status messages throughout all aspects of the SQLJ process--translation, semantics-checking, compilation, and customization.

Messages are output as each file is processed and at each stage of SQLJ operation. The -explain flag instructs the SQLJ translator to include "cause" and "action" information as available with translator error message output for the first occurrence of each error. This will be the. As a result, when Java runtime errors occur, the line number reported by the JVM is the line number in the SQLJ source code, making it much easier to debug. Normally, the instructions in a. This would be of limited use to SQLJ developers, though, as they would still need to map line numbers in the generated.

The SQLJ translator modifies the. This process is known as instrumenting the class file. This option is equivalent to the -linemap option discussed in the preceding section , but you should use it instead of -linemap if you are using the jdb debugger provided with the Sun Microsystems JDK. This is because jdb can access only source files with a.

With Oracle-specific code generation, no profiles are generated, and the SQLJ runtime is largely bypassed during code execution. Because profile customization is not applicable with Oracle-specific code generation, some generally useful optimization options, formerly available only through the Oracle customizer, are now available directly through the SQLJ translator. This option is also available as either a translator option for Oracle-specific code generation or an Oracle customizer option for ISO standard code generation.

This section describes these code generation, optimization, and CHAR comparison options:. With Oracle-specific code generation, there are no profile files and the SQLJ runtime is largely bypassed during program execution. Use the SQLJ translator -codegen option if you want to specify code generation according to the ISO standard the default in previous releases , as follows:. As of Oracle9 i release 2, the default is Oracle-specific SQLJ code generation, but you can also explicitly specify this as follows:.

See "Oracle-Specific Code Generation No Profiles " for information about advantages, disadvantages, limitations, and special considerations regarding Oracle-specific code generation. Use the SQLJ translator -optcols flag to instruct the translator to determine types and sizes of iterator or result set columns. This enables registration of the columns with the Oracle JDBC driver when your application runs, saving round trips to Oracle9 i depending on the particular driver implementation.

Specifically, this is effective for the Thin driver and positional iterators. For an overview of column definitions, see "Column Definitions". This flag is disabled by default, but you can also disable it explicitly. Disable it on the command line as follows:. Column definitions require a database connection for examination of the columns of tables being queried, so the SQLJ translator -user , -password , and -url options must also be set appropriately.

Use the SQLJ translator -optparams flag to enable parameter size definitions. If this flag is enabled, SQLJ will register your input and output parameters host variables to optimize JDBC resource allocations according to sizes you specify, with the following precedence:. If there is no source code hint or default datatype size for a given host variable, then resource allocation is left to JDBC. For an overview of parameter size definitions and a discussion of source code hints, see "Parameter Size Definitions".

This translator option is equivalent to the optparams Oracle customizer option. You can enable or disable the -optparams flag on the command line or in a SQLJ properties file. Unlike the -optcols option, the -optparams option does not require a database connection, because you are providing the size specifications yourself.

Following is a command-line example omitting a setting for the -optparamdefaults option, which is discussed in the next section :. If you enable the -optparams option to set parameter sizes, use the -optparamdefaults option as desired to set default sizes for specified datatypes. If -optparams is not enabled, then any -optparamdefaults setting is ignored.

If a host variable has a source code hint to specify its size, that takes precedence over the corresponding datatype default size set with this option. If there is no source code hint or corresponding datatype default size for a particular host variable, then resource allocation for that variable is determined by the JDBC driver, just as it would be if -optparams were not enabled.

There is no requirement to use the -optparamdefaults option, although it is typically used whenever -optparams is enabled. If -optparams is enabled and there are no default size settings, then resources are allocated either according to source code hints if any or according to the JDBC driver.

This translator option is equivalent to the optparamdefaults Oracle customizer option. You can set the -optparamdefaults flag on the command line or in a SQLJ properties file. All sizes are in bytes.

Do not include any white space. Use empty parentheses for a null setting. The -optparamdefaults option also recognizes group names and wildcards, as follows:.

The -optparamdefaults setting is processed from left to right. When using group names or wildcards, you can override a group setting for particular datatypes. The following example sets a general default size of 50 bytes, overrides that with a setting of bytes for raw types, then overrides the raw type group setting with a null setting for VARBINARY leaving that to JDBC for corresponding host variables with no source code hints :.

Following is a command-line example, including the -optparams setting as well:. If at runtime the actual size exceeds the registered size of any parameter, runtime errors will occur. This way, for example, "mystring" would compare positively against "mystring ". This section documents the syntax and functionality of the advanced flags and options you can specify in running SQLJ, as well as prefixes employed to pass options to the JVM, Java compiler, or SQLJ profile customizer.

See "Properties Files for Option Settings" for more information. Additional advanced options, intended specifically for situations where you are using alternative Java environments, are discussed in "Translator Support and Options for Alternative Environments". More basic command line flags and options are discussed in "Basic Translator Options". This prefix immediately precedes a JVM option, with no spaces in between.

After stripping the -J prefix, the sqlj script passes the -Duser. You cannot pass options to the JVM from a properties file, because properties files are read after the JVM is invoked. The -C prefix marks options to pass to the Java compiler invoked from the sqlj script. This prefix immediately precedes a Java compiler option, with no spaces in between.

After stripping off the -C prefix, the sqlj script passes the compiler option to the Java compiler typically, but not necessarily, javac. After stripping the -C prefix, the sqlj script passes the -nowarn argument as is to the compiler. The -nowarn flag is a javac option to suppress warning messages during compilation. Consider the following example:. Accomplish this by prefixing the JVM option with -C-J with no spaces between this prefix combination and the option.

The -P prefix marks options for customization, as follows:. The -P and -P-C prefixes immediately precede a customizer option, with no spaces in between. After stripping off the prefix, the sqlj script passes the customizer option as is to the profile customizer. One use of the -P prefix is to override the default customizer determined by the SQLJ -default-customizer option, as follows:.

The -backup flag is a generic customizer option to backup the previous customization before generating a new one.

Here is an example of a vendor-specific customizer option in this case, Oracle-specific :. The summary flag is an Oracle customizer option that prints a summary of the customizations performed. For information about available generic and Oracle-specific customizer options, see "Customization Options and Choosing a Customizer". As mentioned above,. A translator takes a program written in source language as input and converts it into a program in target language as output. It also detects and reports the error during translation.

Roles of translator are:. The different types of translator are as follows:. Compiler is a translator which is used to convert programs in high-level language to low-level language. It translates the entire program and also reports the errors in source program encountered during the translation.

Interpreter is a translator which is used to convert programs in high-level language to low-level language. Interpreter translates line by line and reports the error once it encountered during the translation process. It directly executes the operations specified in the source program when the input is given by the user.

Examples of CPUs include those made by Intel e. Compilers Compilers convert high-level language code to machine object code in one session. Compilers can take a while, because they have to translate high-level code to lower-level machine language all at once and then save the executable object code to memory.

A compiler creates machine code that runs on a processor with a specific Instruction Set Architecture ISA , which is processor-dependent. For example, you cannot compile code for an x86 and run it on a MIPS architecture without a special compiler. Compilers are also platform-dependent. A cross-compiler, however, can generate code for a platform other than the one it runs on itself.

A cross-compiler running on a Windows machine, for instance, could generate code that runs on a specific Windows operating system or a Linux operating system platform. Source-to-source compilers translate one program, or code, to another of a different language e. Choosing a compiler then, means that first you need to know the ISA, operating system, and the programming language that you plan to use.

Compilers often come as a package with other tools, and each processor manufacturer will have at least one compiler or a package of software development tools that includes a compiler.

Often the software tools including compiler are free; after all, a CPU is completely useless without software to run on it.



0コメント

  • 1000 / 1000