|
Oracle
SQLJ Frequently Asked Questions
This document contains answers to frequently asked questions
about Oracle's SQLJ drivers. Note that these address specific technical
questions only and are used to document solutions to frequent customer
questions as well as any known problems. Please consult the SQLJ
Developer�s Guide and Reference for full background information.
If you have any questions or feedback on this document,
please e-mail mailto:helpsqlj_us@oracle.com
or mailto:sqljsup_us@oracle.com.
Last updated: 27 April 2001
Quick Jump
Need Troubleshooting?
Go to the Troubleshooting Checklist
to solve a problem or issue you have encountered.
Or, jump directly to one of the following
Have General Questions?
Start the General Questions part,
or go to one of the following
Contents
Part A. Troubleshooting
1. Troubleshooting Checklist
2. Problems Translating
and Compiling SQLJ Programs
2.1 Errors
When Starting the Translator
"Error in sqlj stub: invalid
argument"
"Unable to initialize threads:
..."
"An application error has
occurred... Exception:access violation ..." (in trying to run Sun's JDK
1.1.x on Windows NT/Windows 95)
"ExceptionInInitializerError:
NullPointerException"
"NoClassDefFoundError:
sqlj/tools/Sqlj"
"NoClassDefFoundError:
sun/io/CharToByteConverter"
"Error: SQLJ runtime library
is missing"
"The following character
string is too long:"
"Oracle is not
installed properly on your system. ..."
2.2 Error
Messages Encountered During Translation
JDK 1.3: SQLJ translator hangs
and/or does not show any error messages from the Java compiler
"Cannot load JDBC driver
class oracle.jdbc.driver.OracleDriver"
"Return type XXXX ...
is not a visible Java type"
"Missing equal sign in assignment"
"Warning: Cannot determine
default arguments for stored procedures and functions. May need to install
SYS.SQLJUTL."
"Error: unable to load ... java.lang.NoClassDefFoundError"
"Unable to convert ...Xxx.ser
to a class file"
My code declares a
block-level iterator class, and an instance of this class is later created
and used in the same block. SQLJ appears to translate my code without difficulty,
but javac gives the following error: "Error: Class Xxx not found in type
declaration"
"Error in Java compilation:
CreateProcess: javac"
2.3 Additional
Translation Issues
SQLJ hangs during translation
SQLJ translates but does
not produce any .class files
I encounter a core-dump/stack-trace/out-of-memory
condition during translation
I encounter an out-of-memory
condition during translation
Is there a way to
speed up translation of a .sqlj file with online checking enabled?
Why are database errors
reported as warnings? When I use the Oracle online checker, why do I get
one error and one additional warning from the database?
Type class_name of
host item #nn is not permitted in JDBC
Why was the profile-key
class not generated?
3. Problems Deploying
and Running SQLJ Applications and Applets
3.1 Error
Messages Encountered During Deployment or Runtime
"SQLException: No suitable
driver"
"SQLException:
unable to load connect properties file: connect.properties"
"SQLException:
The network adapter could not establish the connection"
"SQLException: Connection
refused"
"SQLException: ORA-01017: invalid
username/password; logon denied"
"InvalidClassException:
Serializable is incompatible with Externalizable"
"Profile not found, SQL
state 46130"
"ClassNotFoundException:
xxx.yyy_SJProfile0 for class xxx.yyy_SJProfileKeys"
"ORA-29541: class class_name could
not be resolved"
"SQLNullException: cannot
fetch null into primitive data type"
"SQLException: Invalid column
type error"
"SQLException: unable
to convert database class ... to client class ..."
"java.security.AccessControlException
(accessDeclaredMembers)"
"java.lang.ClassCastException:
weblogic.jdbc20.rmi.SerialXxxx"
"java.lang.NoClassDefFoundError:
oracle/jdbc/OraclePreparedStatement"
"NullPointerException at
java.util.zip.ZipFile.read"
JDK 1.2.1: Other
"NullPointerException"
ORA-01000: maximum open
cursors exceeded
ORA-01000 when using OracleConnectionCacheImpl
ORA-01000 when processing
REF CURSORS on the client
3.2 Deploying
and Running in the Oracle Server JavaVM
Performance of Java and
SQLJ in Stored Procedures
User defined and predefined
PL/SQL exceptions in SQLJ Stored Procedures
"ORA-29531 - no method
... in class ..."
Container-Managed EJB
does not commit SQLJ updates
"java.security.AccessControlException:
the Permission (java.net.SocketPermission) has not been granted"
3.3 Using
REF Cursors
Error: class cannot
be constructed as an iterator: classname
How to write a PL/SQL
Stored Procedure that returns a result set or an iterator?
Is it possible to return
a result set from a Java Stored Procedure?
REF CURSORs returned
from Stored Procedures lose scrollability
3.4 Additional
Deployment and Runtime Issues
How can I speed up execution
of my SQLJ application?
I'm having problems with
retrieval of CHAR fields in SELECT statements.
Character comparison
works with "" but not with NULL
Using "WHERE column
IN (value_list)" with a value_list of unknown size
Is SQLJ ignoring my UPDATE
statements?
Can I use host variables in
SQLJ DDL statements?
Does SQLJ support connection
objects obtained from JDBC Connection Pools?
I developed a SQLJ application
with Oracle JDeveloper 3.0 but can't get it to run in my JDK 1.2 environment
I am running against an
Oracle 8.0 database and my SQL object updates are not working.
How can I use SQLJ in middle-tier
(or EJB, or XXX) environment Y?
How can I use SQLJ with Oracle's
BC4J?
How can I use SQLJ with JservApache?
Part B. General Questions
4. SQLJ (and JDBC) Basics
4.1 SQLJ
Resources
Are there SQLJ books and other
resources that would help a newcomer?
Is there an Oracle e-mail address
for SQLJ questions?
Where can I find the SQLJ
source code (known as the "reference implementation") that Oracle has made
available freely to the public and other database vendors?
Where can I download the SQLJ
translator for a given platform?
Why do I find information mentioning
JSQL, I thought it is called SQLJ
Can SQLJ be faster than
JDBC?
4.2 SQLJ Overview
Is SQLJ Y2K-compliant?
What are the pros and cons of choosing
Java and SQLJ over C/C++?
I want to write a Stored
Procedure. Can you explain the difference between SQLJ, JDBC, and PL/SQL?
Is there a reason
to write PL/SQL stored procedures instead of Java stored procedures?
Is there a translator
for PL/SQL Stored Procedures/Packages into Java?
Does SQLJ implement the ANSI SQLJ
specification?
Does SQLJ implement the ISO SQLJ specification?
What software components
are required to translate a SQLJ application? to run a SQLJ application?
Can I use the Oracle
SQLJ translator to translate an application to run against a non-Oracle
SQLJ runtime?
Is SQLJ really database
neutral?
4.3 JDBC Drivers
What should I know about
the Oracle JDBC drivers?
Can Oracle SQLJ be used
with non-Oracle JDBC drivers?
4.4 SQLJ,
JDBC, and JDK Versions
What are the different versions
of Oracle SQLJ and how do I get them?
How do the Oracle SQLJ 8.0.5
and 7.3.4 versions differ from the 8.1.5 versions?
Which versions of Oracle
JDBC and the Sun JDK does each version of Oracle SQLJ support?
Do I need a different set
of SQLJ class files depending on whether I'm running under JDK 1.1.x or
JDK 1.2?
5. SQLJ Language and Programming
In the sample programs, I see
the following import clauses at the beginning of the source code. What
are these packages? Do I need to use the same import statements in my own
SQLJ files?
What's a connection
"context"?
What's an iterator?
How do I create iterator classes
and connection context classes?
What's an execution
"context"?
How do I specify which
connection context instance and/or execution context instance a SQLJ statement
should use?
What exactly does the fetch
size correspond to?
Where is the "Oracle" class
and what does it provide?
Can I use SQLJ to write
multithreaded applications?
Given that SQLJ supports only
static SQL, can I intermix SQLJ and JDBC statements in my source code so
that I can use dynamic SQL in the same application?
6. Oracle-Specific Features
Do I need to do
anything special to use Oracle-specific extensions?
What Oracle-specific features
does Oracle SQLJ support?
What is CustomDatum and
how do I use it?
How can I pass objects between
my SQLJ program and Oracle Stored Procedures?
Can SQLJ interact with PL/SQL in
my source code?
Does Oracle SQLJ support PL/SQL
BOOLEAN, RECORD, and TABLE types as input and output parameters?
Does Oracle SQLJ support
the WHERE CURRENT OF construct?
Does Oracle SQLJ support
DML returning?
Can I use the SQL
object features with a JDBC 8.1.x driver against an 8.0.x database?
Can I use SQLJ to return
PL/SQL arrays from stored procedures?
Does Oracle SQLJ support REF
CURSORS?
7. Translation (and
Compilation and Customization) Process
7.1 Basic
Functionality
How do I run the SQLJ
translator?
What are the fundamental
steps in translating a SQLJ application? What is input and output during
the translation process?
Do I have to customize my
application? Where do I get the customizer utility?
For basic use of SQLJ, how
much do I need to know about profiles (.ser files)?
customizationinterop
What's the difference
between online semantics-checking and offline semantics-checking? What
kinds of checking are done?
I know I can enable
online checking by giving the option -user=scott. How can I disable online
checking?
7.2 Java
Configurations
Can I use Java compilers
other than javac (the standard compiler included with the Sun JDKs)?
Is it possible to use the JDK
1.0.2 version of the javac compiler to compile .java files generated by
the SQLJ translator?
7.3 National
Language Support
Does the Oracle SQLJ translator
provide NLS support?
Can I specify the encoding
for SQLJ to use?
8. Development
Environments
Can I develop and debug SQLJ
programs with Oracle JDeveloper?
Can I develop and debug SQLJ
programs with other IDEs such as Visual Café or Visual J++?
Compiling sqlj via ant
(jakarta)
9. Deploying SQLJ Programs
Can SQLJ be used in Java
applets?
Can an SQLJ Applet
open a connection to a third machine?
For end-users, what browsers
will work with SQLJ applets?
Can SQLJ be used in
middle-tier Java applications?
Can SQLJ be used inside
servlets?
Can SQLJ be used
inside JavaServer Pages?
Can SQLJ applications
work across firewalls?
Can I use operating
system authentication to connect from SQLJ?
10. Running SQLJ Programs
What debugging support
does SQLJ offer?
If I translate an
application with one version of the Oracle SQLJ translator, will I be able
to run the application against a future version of the Oracle SQLJ runtime?
Part A. Troubleshooting
The items in this section provide information regarding
common problems and errors encountered by SQLJ users.
1. Troubleshooting
Checklist
This list should help you to systematically identify a
problem you are encountering and point you to where specific issues are
being addressed in this FAQ.
-
Do you have a JDK installed in your system, and can you say
javac? You can determine your JDK version
by issuing
java
-version
See also "Unable to initialize
threads: ...", "Exception:access violation",
"Error in Java compilation: CreateProcess:
javac", "NoClassDefFoundError: sun/io/CharToByteConverter".
Also note that JDK 1.3 is not supported with SQLJ 8.1.7 or earlier - see
JDK 1.3: SQLJ translator hangs and/or does not show
any error messages from the Java compiler.
-
Do you have the Oracle JDBC drivers installed and in your
PATH/CLASSPATH?
Can you compile and run JDBC programs?
See also "Cannot load
JDBC driver class oracle.jdbc.driver.OracleDriver",, "SQLException:
No suitable driver", "SQLException:
The network adapter could not establish the connection", "SQLException:
Connection refused", "SQLException: ORA-01017:
invalid username/password; logon denied".
-
Do you have the SQLJ translator.zip
and runtime.zip (or runtime11.zip,
runtime12.zip) files in your CLASSPATH?
Can you issue
javap
sqlj.tools.Sqlj
See also "NoClassDefFoundError:
sqlj/tools/Sqlj", "Error: SQLJ runtime
library is missing".
-
Can you start the SQLJ translator and have it print out its
environment by issuing
sqlj
-version-long
See also "Error in sqlj stub:
invalid argument", "ExceptionInInitializerError:
NullPointerException", "Unable to initialize
threads: ...".
-
Can you translate and compile .sqlj
programs offline? You need to have "."
(dot) in your CLASSPATH to compile and run the demo programs supplied with
SQLJ. Additionally, if you use the translator option -d
directory, you need to have directory in your CLASSPATH so
that the SQLJ translator can properly resolve Java classes during all translation
phases.
See also SQLJ hangs during translation,
SQLJ translates but does not produce any
.class files, I encounter a core-dump/stack-trace/out-of-memory
condition during translation, I encounter
an out-of-memory condition during translation, "NullPointerException
at java.util.zip.ZipFile.read".
-
Can you translate and compile .sqlj
programs online?
See also "Cannot load
JDBC driver class oracle.jdbc.driver.OracleDriver", "Warning:
Cannot determine default arguments for stored procedures and functions.
May need to install SYS.SQLJUTL.".
-
Can you run your SQLJ program?
See also Error Messages
Encountered During Deployment or Runtime, unabletoloadconnectproperties,
"InvalidClassException:
Serializable is incompatible with Externalizable", profilenotfound46130,
"ClassNotFoundException: xxx.yyy_SJProfile0
for class xxx.yyy_SJProfileKeys", "ORA-29541: class
class_name could not be resolved", JDK
1.2.1: Other "NullPointerException".
-
Are you trying to deploy and run your application in the
middle tier?
See also "SQLException:
Invalid column type error" and "How can
I use SQLJ in a middle-tier environment".
-
Are you tring to return REF CURSORs from the server to the
client and process them there?
See also Using REF Cursors
-
Are you trying to deploy and run your application in the
Oracle server-side JavaVM or in the Oracle iAS JavaVM?
See also Deploying and Running
in the Oracle Server JavaVM.
If your issue is not resolved by this FAQ, you may want to
use Oracle support (http://support.oracle.com/)
or the SQLJ&JDBC discussion forum on http://technet.oracle.com.
Please make sure to provide sufficient information about your environment
and about the problem you have. Below is a list of information you may
want to supply.
SQLJ Error Report
Environment Description
Platform/OS Version:
Database version:
PATH value:
CLASSPATH value:
SQLJ_OPTIONS value:
JDK version (java -version):
JDBC version:
SQLJ version (sqlj -version-long):
Problem Description
Problem Area:
_ unable to start translator
_ translation problem - _ offline or _ online
_ runtime problem
_ deployment problem
Error Message:
Error Description:
2.
Problems Translating and Compiling SQLJ Programs
The following problems might be encountered when trying
to invoke the translator, or during translation itself. The first and second
group of questions address specific error messages; the third group addresses
somewhat more general questions.
In either group, some problems may be indicated as being
general configuration issues, not specific to your SQLJ code. In these
cases, or for general information about SQLJ installation and configuration,
see the "Getting Started" chapter of the SQLJ Developer's Guide and
Reference.
In brief, before concerning yourself with particular code
issues in your application, you should be sure that you can already run
the Java compiler, connect to the database using JDBC, and invoke the translator.
2.1
Errors When Starting the Translator
"Error in sqlj stub:
invalid argument"
(This is likely a general configuration issue, not something
specific to your code.)
The SQLJ translator issues: "Error
in sqlj stub: invalid argument" when it is launched. This may happen
with SQLJ 8.1.6 on a Windows platform. The problem occurs when the SQLJ
wrapper executable sqlj.exe calls
java
<java_arguments> sqlj.tools.Sqlj
<sqlj_arguments>
The problem may have to do with the size of the CLASSPATH.
Also note that SQLJ does not currently support a CLASSPATH
containing one or more spaces.
You can have SQLJ display (but not run) the full Java
command line above by issuing
sqlj
-n <options>
You can try to resolve this issue with one or more of the following:
-
Obtain a different sqlj.exe
stub (such as from the SQLJ 8.1.7 or later distribution, or from SQLJ 8.1.5
or another earlier SQLJ download)
Also note that the SQLJ downloads on OTN contain the
C-source code for the wrapper executable.
-
You can try to reduce the size of the CLASSPATH
to a minimum, for example to "." (dot),
the JDBC classesXXX.zip,
the SQLJ translator.zip, and the SQLJ runtime.zip
(see also "Unable to initialize threads:
...").
-
As a workaround, you can also issue
java
sqlj.tools.Sqlj <options>
"Unable to initialize
threads: ..."
(This is likely a general configuration issue, not something
specific to your code.)
If you are using the Java Development Kit from Sun, you
may be experiencing problems from conflicts with previously installed Java
environments. The easiest way to avoid such problems is to customize your
CLASSPATH setting to include only what
you need for the JDK, the JDBC driver, and SQLJ. Essentially, you should
start with a clean slate.
You can accomplish this as follows:
-
Clear the CLASSPATH.
-
Add "." (current directory)
to the CLASSPATH and then make sure you
can run java and javac.
-
Add the appropriate JDBC ZIP file--classes111.zip
for JDK 1.1.x, or classes12.zip for JDK
1.2. These files are in the JDBC lib directory,
such as the following on Solaris:
[Oracle
Home]/jdbc/lib/classes12.zip
or the following on Windows NT:
[Oracle
Home]\jdbc\lib\classes12.zip
-
Add the SQLJ ZIP file translator.zip.
This file is in the sqlj/lib directory,
as with the JDBC classesXX.zip files above.
-
Add the SQLJ ZIP file runtime.zip.
This file is in the sqlj/lib directory.
Notes:
-
You do not need to add the runtime zip if you are using SQLJ
8.1.6 or earlier, but it will not hurt, either.
-
For Sun JDK 1.1.3 or higher, you should not need the JDK
directory to appear in the CLASSPATH (in
fact, it may be advisable to not have it in the CLASSPATH).
(This discussion is regarding the CLASSPATH
environment variable, as opposed to the Java/SQLJ -classpath
option. When using the -classpath option,
you do have to include the JDK directory.)
-
A convenient approach to going back and forth between your
normal CLASSPATH and your CLASSPATH
for SQLJ would be to create a script (for Solaris) or a batch file (for
Windows) to set up each configuration.
"An application error
has occurred... Exception:access violation ..." (in trying to run Sun's
JDK 1.1.x on Windows NT/Windows 95)
(This is likely a general configuration issue, not something
specific to your code.)
This may also be caused by PATH
or CLASSPATH problems. See the answer to
the previous question.
"ExceptionInInitializerError:
NullPointerException"
(This is likely a general configuration issue, not something
specific to your code.)
If you see the following stack trace:
unexpected error occurred...
java.lang.ExceptionInInitializerError: java.lang.NullPointerException
at sqlj.framework.ClassFileReader.attribute_info(Compiled
Code)
...
at sqlj.tools.Sqlj.statusMain(Compiled
Code)
at sqlj.tools.Sqlj.main(Sqlj.java:117)
then you are likely running SQLJ version 8.1.5 or earlier
under JDK 1.2.x or later.
If you are using the command-line version of SQLJ, download
and install SQLJ 8.1.6 or later.
If you are using SQLJ from JDeveloper 3.0, download the
SQLJ 8.1.6 SDK patch, which contains a translator.zip
version to replace the one included in JDeveloper 3.0.
"NoClassDefFoundError:
sqlj/tools/Sqlj"
(This is likely a general configuration issue, not something
specific to your code.)
The error "Exception in thread main java.lang.NoClassDefFoundError:
sqlj/tools/Sqlj" indicates that the SQLJ translator class files cannot
be found. Most likely, your CLASSPATH is
missing the SQLJ translator.zip file. This
file can usually be found in [Oracle Home]/sqlj/lib/.
Also remember to add one of the SQLJ runtime zip files to the CLASSPATH
� this is required in SQLJ version 8.1.7 and later (see "Error:
SQLJ runtime library is missing").
"NoClassDefFoundError:
sun/io/CharToByteConverter"
(This is likely a general configuration issue, not something
specific to your code.)
Running sqlj results in
the following error message.
java.lang.NoClassDefFoundError:
sun/io/CharToByteConverter
at sqlj.tools.Sqlj.initializeErrors(Sqlj.java:519)
This happens if you are running under a JRE environment,
and not a full JDK environment. You need to download and install a full
JDK environment. Note that the Oracle database installation will only set
up a Java Runtime Environment. Oracle does not distribute the Java Development
Kit - you have to get it from http://java.sun.com
"Error: SQLJ
runtime library is missing"
(This is likely a general configuration issue, not something
specific to your code.)
This indicates that your CLASSPATH
contains the translator.zip file, but is
missing the runtime library. The SQLJ library files can usually be found
in [Oracle Home]/sqlj/lib/.
-
Add runtime.zip to your CLASSPATH
if you want to use SQLJ with any JDBC driver � not just the one that corresponds
in version to your SQLJ version. For example, if you have SQLJ 8.1.7 and
want to use it with any one of the following JDBC versions: 7.3.4, 8.0.5,
8.1.5, 8.1.6, or 8.1.7.
-
Add runtime11.zip to your
CLASSPATH if your SQLJ and JDBC versions
match and you are running in a JDK 1.1.x environment. This runtime provides
a slightly better performance and is also the recommended runtime for applet
environments.
-
Add runtime12.zip if your
SQLJ and JDBC versions match and you are running in a JDK 1.2 or later
environment. This is necessary for certain JDBC 2.0 features, such as support
for java.sql.SQLData through type maps.
You can also use runtime12ee.zip
if your SQLJ and JDBC versions match and you are running in a JDK 1.2 or
later environment that provides support for the packages javax.naming
and javax.sql.
"The following character
string is too long:"
This is likely a result of the SQLJ command line being
too long when invoking the SQLJ translator on Windows. You can do the following
to reduce the size of the command line.
-
Do not provide .java files
on the command line but rely on the implicit make
capability in both, the SQLJ translator and the Java compiler. Note, however,
that you must mention all of the .sqlj
files that your program requires, do not rely on implicit make
to find all of those.
-
You can perform the -ser2class
conversion (if required), as well as Java compilation and profile customization
in separate steps. Use the setting -compile=false
to turn off Java compilation.
-
Place as many command line options as possible into the sqlj.properties
file. Note that options in the SQLJ_OPTIONS
environment variable are passed on the command line, while options in the
sqlj.properties file are not.
-
Your operating system may permit you to increase the size
of the environment (and this may or may not increase the maximum command
line length as well).
"Oracle
is not installed properly on your system. ..."
This message may be encountered with SQLJ 8.1.6 on Windows.
The problem is that the SQLJ wrapper executable (sqlj.exe)
is unable to determine the location of the Oracle installation from the
system registry and exits.
-
Try the following as a sanity check:
- add the translator.zip
library of your Oracle installation (OracleHome/sqlj/lib/translator.zip)
to your CLASSPATH, as well as the classes111.zip
(or classes12.zip) from the Oracle JDBC
driver
- run: java sqlj.tools.Sqlj
-version-long to see whether SQLJ finds everything it needs.
-
If SQLJ appears to work fine without the sqlj.exe
wrapper, you should use the original wrapper that came with SQLJ 8.1.5/8.0.5/7.3.4
(and that is also distributed with SQLJ 8.1.7 and later). Download SQLJ
8.0.5, or 8.1.7 or later from the OTN download page at http://technet.oracle.com/,
unzip it, and use that sqlj.exe file instead
of the one that came with your Oracle installation.
2.2
Error Messages Encountered During Translation
SQLJ translator hangs
and/or does not show any error messages from the Java compiler (in JDK
1.3)
When using SQLJ 8.1.7 or earlier under JDK 1.3 you may
experience hangs, or you will notice that Java compilation errors do not
show up anymore. (If you experience hangs and are not using JDK 1.3 or
later, please see SQLJ hangs during translation)
The problem is that with JDK 1.3 the javac
compiler sends error messages to standard error instead of standard output.
However, the SQLJ translator tries to capture messages from standard error.
Since this issue affects Oracle SQLJ versions 8.1.7 and earlier, you may
want to upgrade to SQLJ version 9.0.1 or later. Otherwise you may be able
to use the following workaround.
-
First, create a new shell script that invokes javac
but that also sends stderr to stdout. For example, if you can invoke the
Unix shell sh, you might create the following
executable script called myjavac and place
it in your PATH:
#!/bin/sh
# sh
script myjavac to redirect stderr to stdout
javac
"$@" 2>&1
-
Secondly, you need to tell SQLJ to use the -passes
option and also to invoke the myjavac shell
script instead of calling the javac compiler:
sqlj
-passes -compiler-executable=myjavac Foo.sqlj
Note that you cannot put the -passes
option into the sqlj.properties file, since
it must be processed by the sqlj wrapper
script/executable. Since you probably do not want to type these two options
by hand every time you invoke SQLJ, you may prefer to put them in the SQLJ_OPTIONS
environment variable. Depending on your operating system and command line
shell, you might say something along the following line (here shown for
a csh-like shell):
setenv
SQLJ_OPTIONS "-passes -compiler-executable=myjavac"
If you are running on a Windows platform, you need to use
a shell that is able to redirect standard error to standard output. If
you are running in a DOS shell, you will not be able to perform this redirection.
In this case, you should omit the -compiler-executable
flag shown above but still use the -passes
flag. This will ensure that you can still see the javac
error messages. However, in this case errors will be shown in terms of
the generated .java files and not the original
.sqlj source. Note that using the -passes
option incurs a slight performance penalty: a JavaVM is started with the
SQLJ translator, terminated, the javac
compiler is run, and then the translator is started in a new JavaVM to
process the output of javac. Without the
-passes option, only a single JavaVM with
the SQLJ translator is started. The javac
compiler is called as a subprocess from that VM.
"Cannot load
JDBC driver class oracle.jdbc.driver.OracleDriver"
When SQLJ translation results in the following warning:
Cannot
load JDBC driver class oracle.jdbc.driver.OracleDriver.
You need to have the JDBC classes111.zip
(for JDK 1.1.x) or classes12.zip (for JDK
1.2 or later) in your CLASSPATH environment
variable. The following command line should print out the methods on the
OracleDriver class.
javap
oracle.jdbc.driver.OracleDriver
Subsequently, the following should print out all sorts
of version information on SQLJ, JDBC and the JDK you are using.
sqlj
-version-long
If this shows the JDBC driver version as 0.0, then the
Oracle JDBC driver is not yet in the CLASSPATH.
"Return type
XXXX ... is not a visible Java type"
You may be trying to return an iterator instance from
a stored procedure, or as a column of a result set, and this iterator type
is declared as follows:
#sql iterator MyIter (String
brand_name);
Change this declaration to read as follows (assuming the
iterator is declared as a nested class):
#sql public static iterator
MyIter (String brand_name);
The problem is that the SQLJ runtime has to manufacture an
instance of the MyIter iterator type. This
only works if the iterator type is a public class.
"Missing equal
sign in assignment"
This may be caused by using the pre-ANSI style of connection
contexts, using parentheses instead of brackets. Instead of:
#sql (context_instance) { DROP
TABLE test };
use:
#sql [context_instance] { DROP
TABLE test };
"Warning: Cannot
determine default arguments for stored procedures and functions. May need
to install SYS.SQLJUTL."
(This is a general configuration issue.)
The SQLJUTL package should
be installed automatically in the SYS schema.
It is used for semantics-checking of Oracle stored procedures and functions
that have been defined to have default arguments.
If the translator indicates that it cannot find SQLJUTL,
use the following SQL command (from SQL*Plus, for example) to see if it
exists:
describe sqljutl
This will provide a brief description of the package if it
can be found. If not, you will have to install it manually in the SYS schema,
which on Solaris (for example) can be accomplished using the following
script:
[Oracle Home]/sqlj/lib/sqljutl.sql
You must connect to the SYS
schema, such as by logging in as INTERNAL,
SYS, or CONNECT/AS
SYSDBA to install this package. Consult your installation instructions
if necessary.
"Error: unable to load
... java.lang.NoClassDefFoundError"
This may indicate that the translator cannot find your
compiled .class files during customization,
and is particularly likely if you are using a Java package structure and
are not using the SQLJ -d option during
translation.
As a first step, rerun the translator with the -status
flag enabled. If this error occurs after the [Customizing]
line in the status output, this indicates a problem in finding your .class
files during customization.
You can avoid this problem by using the SQLJ -d
option when you translate. This option allows you to specify a root directory,
and all profiles and .class files are placed
underneath that root directory according to the package structure. Also,
note that this directory must be in your CLASSPATH.
"Unable to convert
...Xxx.ser to a class file"
This occurs if you are using the SQLJ -ser2class
option (to convert .ser profiles to .class
files) and the translator cannot find the .ser
files to convert. This problem is similar to the NoClassDefFoundError
discussed in the previous question, and can also be resolved by using the
SQLJ -d option during translation.
My code declares
a block-level iterator class, and an instance of this class is later created
and used in the same block. SQLJ appears to translate my code without difficulty,
but javac gives the following error: "Error: Class Xxx not found in type
declaration"
This problem, where Xxx
is the iterator class name, results from a known bug in the javac
compiler, version 1.1.x. Here is an example of a method that would result
in this error:
void method() throws SQLException
{
#sql iterator BlockIter
(int col1, String col2);
BlockIter i;
#sql i = { SELECT
col1, col2 FROM tab };
while (i.next())
{ ... }
}
The error location is somewhere within the code generated
for the SELECT operation. The problem is
that block-level classes can be referenced in the same block as they were
declared, but not from within blocks within the declaring block. SQLJ generates
code for the above SELECT operation as
a statement block, and thus cannot instantiate a BlockIter
instance within the generated block. A workaround is to declare the iterator
at the class-level rather than the block-level. (This problem does not
occur with JDK 1.2.)
"Error in Java
compilation: CreateProcess: javac"
If the following error occurs during translation.
Error in Java compilation:
CreateProcess:
javac -J-Djavac.pipe.output=true
<filename> error=2
Try one or more of the following.
-
Ensure that you have installed the Java Development Kit from
http://java.sun.com . Specifically,
you should be able to run javac from the
command line.
-
Reduce your PATH and CLASSPATH setting to the bare minimum
to exclude possible conflicts of JavaVM's (you can do that most easily
with a script or .bat file - see below; also see "Unable
to initialize threads: ...").
-
Add the -passes option to
invoke the Java compiler in a different way.
Note: If you want to use a non-JDK command line environment
to compile your SQLJ programs, please refer to "Can
I use Java compilers other than javac (the standard compiler included with
the Sun JDKs)"
2.3
Additional Translation Issues
SQLJ hangs during translation.
If you are using JDK 1.3 then please see "JDK
1.3: SQLJ translator hangs and/or does not show any error messages from
the Java compiler". If the SQLJ translator appears to hang during translation,
interrupt the translation and add the -status
flag to diagnose the problem:
sqlj -status ....
If, after doing this, you find that the last message issued
by the SQLJ translator is the following line:
[Compiling]
then the problem occurs during invocation of the Java compiler
by the SQLJ translator. In this case you need to always add the -passes
option to the SQLJ command line:
sqlj -passes ...
Alternatively, you can add -passes
to the SQLJ_OPTIONS environment variable:
SQLJ_OPTIONS=-passes ...
If, however, the hang occurs before the SQLJ compilation
process, you might be translating with a 7.3.x JDBC driver with online
semantics-checking enabled. In this case, you must either forego online
checking, or upgrade to a newer JDBC driver version (at least an 8.0.x
JDBC driver instead of a 7.3.x driver).
Note: If you are using SQLJ 8.1.5, 8.0.5, or 7.3.4
on NT, you should always use the -passes
options. Otherwise you will experience this hang.
SQLJ translates
but does not produce any .class files
If you run the SQLJ translator, but Java compilation appears
to fail silently (you can verify with the -status
command line option whether compilation was started) you can try one or
more of the following.
-
Ensure that you have installed the Java Development Kit from
http://java.sun.com .
-
Reduce your PATH and CLASSPATH setting to the bare minimum
to exclude possible conflicts of JavaVM's (you can do that most easily
with a script or .bat file - see below; also see ).
-
Add the -passes option to
invoke the Java compiler in a different way.
I encounter a core-dump/stack-trace/out-of-memory
condition during translation.
If no previously discussed diagnosis fits your problem,
you may want to try the following.
-
Turn off your JavaVM's JIT (just-in-time) compiler. You might
be able to use one of the following to accomplish this:
Add the -J-Djava.compiler=none
command-line flag to the translator invocation.
or:
Set the JAVA_COMPILER=NONE
environment variable.
-
Re-set your CLASSPATH variable
to only contain . (current directory), the JDBC driver (either classes111.zip,
or classes12.zip), the SQLJ translator
(translator.zip), for SQLJ 8.1.7 or higher
a SQLJ runtime (runtime.zip, runtime11.zip,
or runtime12.zip), and any other classes
that are actually referenced by your source, other than classes that are
part of your JDK (the JDK classes do not have to be in your CLASSPATH
for JDK 1.1.3 or higher).
I encounter an out-of-memory
condition during translation.
If you have a genuine out-of-memory condition during SQLJ
translation (as opposed to the issue described in the preceding question),
you can increase your Java VM's memory allocation by passing additional
flags to the SQLJ translator.
For example, you can set a heap size of 128 MBytes for
the JDK 1.1.x Java VM with the -mx128M
flag. By prefixing this flag with -J, you
can use it with the SQLJ translator as follows:
sqlj -J-mx128M ...
Note that you must either pass this flag on the command
line, or place it in the SQLJ_OPTIONS environment
variable.
Also note that the -mx
flag has changed to -Xmx in JDK 1.2.
Is there
a way to speed up translation of a .sqlj file with online checking enabled?
If you enable the translator cache option (-cache=true),
then SQLJ remembers the result of online checking and stores it in the
file SQLChecker.cache. This removes the
need to connect to the database for every #sql
statement in your program. Note, however, that only those SQL statements
that do not result in error or warning messages are being cached. Whenever
SQLChecker.cache has become too large,
or you want to start with a clean cache, you can just delete file SQLChecker.cache
before running SQLJ.
Why are database
errors reported as warnings? When I use the Oracle online checker, why
do I get one error and one additional warning from the database?
Errors reported by the database are passed on as warnings
by SQLJ. This is because the database reporting may not be fully accurate,
resulting in spurious errors. The signature of stored functions and procedures
is analyzed directly from the SQLJ client. But these function and procedure
invocations are also passed to the database for explicit analysis. This
results in duplicate reporting of certain errors or warnings concerning
stored procedures and functions.
"Type class_name
of host item #nn is not permitted in JDBC"
What does the following warning message mean?
Type package_name.class_name
of host item #1 is not permitted in JDBC. This will not be portable.
This warning is issued if you use Java types that are supported
by Oracle's JDBC driver (and thus in the Oracle SQLJ runtime), but that
are not JDBC types. You would only care about this warning if you want
to write fully portable code. You can turn off portability warnings in
JDeveloper under project properties on the SQLJ tab. On the SQLJ command
line you could say: -warn=noportable.
Why was
the profile-key class not generated?
I used the SQLJ translator to translate a couple of .sqlj
files. Some of them have profile-key classes associated but some don't.
Can you tell me why? Do missing profile-key classes hurt?
A profile keys class (and associated .ser
files) will only be generated if you have an actual SQLJ statement, that
is:
#sql ...
{ ... some SQL statement ... };
in your .sqlj file. If, on
the other hand, you only have declarations, such as:
#sql public iterator MyIter
(...);
or
#sql public context MyContext;
in your .sqlj source (and
no statements), then no profile needs to be generated. Additionally, the
FETCH statement:
#sql { FETCH :iter INTO :x,
:y, :x };
is translated directly into Java and needs no profile information,
either.
In SQLJ version 9.0.1 and later, you can specify the command
line option -codegen=oracle. This results
in the direct generation of Oracle JDBC code. In this neither .ser
nor profile keys file are being generated for any of your SQLJ statements.
3.
Problems Deploying and Running SQLJ Applications and Applets
For general information about deploying and running SQLJ
programs, see "Deploying SQLJ Programs" and "Running SQLJ Programs" later
in this FAQ.
3.1
Error Messages Encountered During Deployment or Runtime
"SQLException:
No suitable driver"
(This is likely a general configuration issue, not something
specific to your code.)
If you see the exception trace:
java.sql.SQLException: No suitable
driver
at java.sql.DriverManager.getConnection(Compiled
Code) ...
at oracle.sqlj.runtime.Oracle.getConnection(Compiled
Code)
at oracle.sqlj.runtime.Oracle.connect(Compiled
Code)
then you probably have not added the Oracle JDBC driver ZIP
file to your CLASSPATH. Either use:
[Oracle Home]/jdbc/lib/classes111.zip
(for JDK 1.1)
or:
[Oracle Home]/jdbc/lib/classes12.zip
(for JDK 1.2)
Furthermore, you need to ensure that your JDBC driver is
registered with the java.sql.DriverManger.
If you are using the server-side (kprb)
JDBC driver, or if you used one of the methods connect()
or getConnection() on oracle.sqlj.runtime.Oracle
to obtain a SQLJ connection context, then this will happen automatically.
Otherwise you need to register the Oracle JDBC driver, for example as follows:
java.sql.DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
Additionally, you need to ensure that you are specifying
a correct URL. For example, if you are using the connect method:
oracle.sqlj.runtime.Oracle.connect
(MyApp.class,"connect.properties");
then you should verify that connect.properties
is available in the same directory as MyApp.class,
and contains something equivalent to the following:
sqlj.url=jdbc:oracle:thin:@localhost:1521:orcl
sqlj.user=scott
sqlj.password=tiger
(Use the name of your host instead of localhost,
your port number instead of 1521, and the
name of your database instance instead of orcl.)
"SQLException:
unable to load connect properties file: connect.properties"
When trying to establish a SQLJ connection using the code
Oracle.connect(SomeClass.class,
"connect.properties");
you encounter the message
"java.sql.SQLException: unable
to load connect properties file: connect.properties"
In this situation you need to verify the following properties
of the Oracle.connect method:
-
The connect.properties resource
must be found either on the CLASSPATH,
or -if deployed- in a .jar file in the
same package as the class SomeClass.class.
In other words, assuming you are deploying your application in a .jar
file.
-
If SomeClass is a top-level class, then connect.properties
should be in the .jar's root directory.
-
If SomeClass is actually of the form A.B.C.SomeClass,
then connect.properties must be in the
/A/B/C subdirectory of the .jar
file.
-
The entries in the connect.properties
file must use the following SQLJ-specific format:
sqlj.user=<schema
name>
sqlj.password=<user
password>
sqlj.url=<JDBC
URL>
"SQLException:
The network adapter could not establish the connection"
(This is likely a general configuration issue, not something
specific to your code.)
The message: "The network adapter could not establish
the connection." means one of two things:
-
The host could not be reached or does not exist. Please use
the ping program to verify that the host
is accessible on the network.
-
The host does not have a TNS listener running on the specified
IP address. You can use the Net8 Configuration assistant to configure a
database listener for TCP/IP. Alternarively -for example under Unix- you
can do this by editing your listener.ora
file, adding an additional line to:
LISTENER
= (ADDRESS_LIST=
(ADDRESS=(PROTOCOL=ipc)(KEY=oracle-sid)) )
as follows:
LISTENER
= (ADDRESS_LIST=
(ADDRESS=(PROTOCOL=ipc)(KEY=oracle-sid))
(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=port)) )
Now you must stop and then re-start your listener to
pick up the new settings:
lsnrctl
stop; lsnrctl start
"SQLException: Connection
refused"
(This is likely a general configuration issue, not something
specific to your code.)
If a listener is up and running as specified, but there
is no database with the
specified Oracle SID, you will see the message:
java.sql.SQLException: Io exception:
Connection refused(...)
"SQLException: ORA-01017:
invalid username/password; logon denied"
If the username and/or password is not valid, you get:
java.sql.SQLException:
ORA-01017: invalid username/password;
logon denied
"InvalidClassException:
Serializable is incompatible with Externalizable"
(This is likely a general configuration issue, not something
specific to your code.)
If you see the exception:
java.sql.SQLException: profile
xxx.yyy_SJProfile0 not found:
java.io.InvalidClassException:
[java.lang.Object; Serializable
is incompatible with Externalizable
then you may have a discrepancy between the Java environment
that you use to translate SQLJ and the environment that you use to customize/run
SQLJ.
-
If you are using SQLJ from JDeveloper 3.0, download the SQLJ
8.1.6 SDK patch, which contains a new translator.zip
version for replacing the translator.zip
file from the JDeveloper 3.0 installation. You must also ensure that the
following all match: the JDK version (such as JDK 1.2.2) with which JDeveloper
is started, the JDK version used by your project (see your project properties),
and the JDK-compatible JDBC ZIP file (such as classes111.zip
or classes12.zip).
-
If you are using the command-line version of SQLJ, download
and install SQLJ 8.1.6 or later or the SQLJ 8.1.6 SDK patch release.
-
If you are deploying compiled SQLJ code into an Oracle database
(for example, as a Java Stored Procedure, or as an Enterprise Java Bean),
then you may want to use the same JDK and SQLJ versions for client compilation
that are used in your server JavaVM. Specifically, for Oracle 8.1.7 or
higher you may want to use the corresponding runtime12.zip
and JDK 1.2, for Oracle 8.1.6 you want to compile under JDK 1.2, and for
Oracle 8.1.5 you want to compile using JDK 1.1.x.
"Profile not found,
SQL state 46130"
You may see this error if you have deployed SQLJ code
to the server-side Java VM and are subsequently trying to run it. The error
occurs because the SQLJ .ser profile files
have not been deployed with the rest of your application, or they may not
have been deployed into the same package as the original SQLJ classes that
they reference. Please refer to the explanation of the error "ClassNotFoundException:
xxx.yyy_SJProfile0 for class xxx.yyy_SJProfileKeys" directly below.
"ClassNotFoundException:
xxx.yyy_SJProfile0 for class xxx.yyy_SJProfileKeys"
If you see an exception such as:
java.sql.SQLException: profile
xxx.yyy_SJProfile0 not found:
java.lang.ClassNotFoundException:
xxx.yyy_SJProfile0 for class
xxx.yy_SJProfileKeys
then you must ensure that the SQLJ profile(s), such as xxx/yyy_SJProfile0.ser,
is available in the SQLJ runtime environment. This includes JARing this
file as part of an applet deployment, or publishing it to the server via
loadjava.
Setting a root directory. You may want to use the
SQLJ -d <rootdir> flag
to ensure that all files required by your project are deposited under a
particular directory hierarchy before you run jar
or loadjava.
Applets and converting .ser to .class. There is
an additional consideration for applets. Older browser versions that are
based on JDK 1.0.2, such as Netscape Navigator 3.0 and Microsoft Internet
Explorer 3.0, did not have support for loading a serialized object from
a resource file associated with the applet. Additionally, the Navigator
browser does not permit resources to be loaded from files with a ".ser"
extension. These limitations also result in the ClassNotFoundException
when you try to run the applet. As a work-around, specify the SQLJ translator
-ser2class option when you translate the
code. This instructs SQLJ to convert profiles into Java class format in
.class files. If you translate MyApplet.sqlj
this way, for example, the profile would be in MyApplet_SJProfile0.class
instead of MyApplet_SJProfile0.ser. Then
you would have to ensure that the profile .class
file is available in the SQLJ runtime environment, as with a profile .ser
file.
Deploying code to the server, such as Java Stored Procedures
and Enterprise Java Beans. Essentially, you have three choices in uploading
your code with loadjava: (1) you can upload
source code and have the server compile your code, (2) you can upload .class
and .ser files, and (3) you can convert .ser
files to .class files and upload these together with the other .ser
files. If you use method (2) or (3) and omit one or more .ser and -respectively-
converted .class files, you will encounter the ClassNotFoundException
when your program is run.
Notes:
-
In JDeveloper 3.0 and earlier the -ser2class
flag is not supported. You will have to use the sqlj
command-line translator to obtain this functionality. Additionally, SQLJ
provides a stand-alone tool ("profconv")
for converting .ser files into .java
files (and subsequently .class files) that
permits full control over the conversion process. Issue the following to
obtain a synopsis of the tool:
java
sqlj.runtime.profile.util.SerProfileToClass
-
In SQLJ 8.1.6 and earlier only .ser
files of less than 32KB can be transformed in this way.
"ORA-29541: class class_name
could not be resolved"
My SQLJ program precompiles and compiles successfully,
resulting in a .class file which I load without error using loadjava. I
then create a procedure to run the stored procedure. When I run the procedure,
I get the error:
ORA-29541: class class_name
could not be resolved
Any of the following things should help:
-
Add the generated .ser file(s)
to be loaded by loadjava.
-
Use the -ser2class option
when translating your SQLJ source and add the additional .class files to
be loaded by loadjava.
-
Use loadjava to load SQLJ
source rather than .class (and .ser)
files.
See also the question "ClassNotFoundException: xxx.yyy_SJProfile0
for class xxx.yyy_SJProfileKeys" above.
"SQLNullException:
cannot fetch null into primitive data type"
You cannot assign a null
value to a Java primitive type (such as |