NoSuchMethodError: sqlj.runtime.ExecutionContext.getOracleContext()
Hello,
so i have some of this code in my project
<code>
OrdHttpUploadFormData formData = new OrdHttpUploadFormData(request);
formData.parseFormData();
OrdHttpUploadFile image = formData.getFileParameter("image");
OrdHttpUploadFile audio = formData.getFileParameter("audio");
OrdImage ord_image_zdjeciealbumu =
(OrdImage) rset.getORAData(1, OrdImage.getORADataFactory());
OrdAudio ord_audio_utwor =
(OrdAudio) rset.getORAData(2, OrdAudio.getORADataFactory());
try {
image.loadImage(ord_image_zdjeciealbumu);
audio.loadAudio(ord_audio_utwor);
} catch (Exception e) {
</code>
Generally my problem is such exception :
<code>
java.lang.NoSuchMethodError: sqlj.runtime.ExecutionContext.getOracleContext()Lsqlj/runtime/ExecutionContext$OracleContext;
oracle.ord.im.OrdImageBase._deleteContent(OrdImageBase.java:322)
oracle.ord.im.OrdImage.deleteContent(OrdImage.java:846)
oracle.ord.im.OrdImage.loadDataFromInputStream(OrdImage.java:749)
oracle.ord.im.OrdHttpUploadFile.loadImage(OrdHttpUploadFile.java:544)
PhotoAlbumRequest.dodajElementDoBazy(Index.java:584)
Index.doPost(Index.java:91)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
</code>
I would like to say that i imported such libraries in my Netbeans project like classes12.jar, runtime12.jar and translator.jar and it still not working. Much appreciated for help.
Here's the relevant JavaDoc on NoSuchMethodError:
Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.
Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
Sounds like you have an incompatibility amongst your Oracle JAR files.
Similar Messages
-
Sqlj runtime error with oracle 10G in Websphere6 or 5.1
We are trying to migrate from oracle 9i to 10G and we are compiled all our sqlj code with codegen = -oracle option.(previously we used to use codegen=-jdbc which for some reason doesnot work).it compiles fine with out any erros.. But when we try to run then get this exception.
java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso. java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso.
at sqlj.runtime.ref.ConnectionContextImpl.getOracleConnection(ConnectionContextImpl.java:167)
at sqlj.runtime.ExecutionContext$OracleContext.prepareOracleStatement(ExecutionContext.java:1397)
We are using ojdbc14.jar that came with oracle 10G.
Hope any one can give any pointers.I'm having same issue - but I'm having it when I try to invoke a method that contains a database Object type from a Tibco Business Works Process called a Java Method.
How exactly do you do the codegen=iso configuration?
I've tried:
1. Project Properties / Compiler SQLJ and then select from Code Generation drop down iso.
2. From Connections / Database / Navigate to package / right-click / Generate Java / Browse to my custom jpub.properties file where I have tried multiple entries such as (by themselves and in some combination.:
- jpub.codegen=jdbc
- jpub.codegen=iso
- jpub.compatible=9i
- jpub.compatible=8i
- compatible=both8i
- jpub.usertypes=oracle
- jpub.compatible=customdatum
- jpub.compatible=sqlj
I've also played with changing from the default some of the Mapping Options in Connections / Database / Navigate to package / right-click / Generate Java / Mapping Options.
This doc here, says that code should change (section 6 JPublisher Input Files - based on configuration of Input files)
Oracle® Database
JPublisher User's Guide
10g Release 2 (10.2)
B14188-01
No matter what I do, the code that gets generate is the same.
Also, the documentation talks about running things from the command line but how exactly do you do that? Do I need to be in specific directory? I tried the c:\ C:\jdev\system and c\jdev\ and c:jdev\bin and always get error message: 'jpub' is not recognized as an internal or external command, operable program or batch file.
I've built a java client in JDeveloper to successfully call the same method and I don't see the error.
Edited by: disaak on Mar 9, 2010 11:51 AM -
SQLJ runtime exception in 9.2.0.4
Hi,
I work on a software using oracle, java and SQLJ technology. Since we pass from oracle 8.1.6 to Oracle 9.2.0.4 we have some sqlj runtime exception. These exceptions are randoms, amazing as the same request with SQL*plus is working, and occurrs randomly in time so it works all the same ...
examples (in bold the oracle exception text) :
1/ Unable to define propagation alert iterator (this exception is an SQL one and catched within the program) : Invalid column name
the sqlj command corresponding => #sql ppgAlertIter = { SELECT USER_LOGIN FROM ALERT WHERE SAFETY_EVENT_ID = :incId AND OCCURRENCE_ID = :occId AND USER_LOGIN IN ( SELECT USER_LOGIN FROM USERS WHERE ROLE_NAME <> :roleName) };
all the column names are rights !!!!
2/java.lang.NullPointerException at sqlj.runtime.ExecutionContext$OracleContext.oracleExecuteQuery(ExecutionContext.java:1585) at asmtdb.DBUser.getComponentUpdateTime(DBUser.java:882)
here is a runtime exception (not catched) (this exception correpsonds to the SQLJ commqnd in example 3/)
3/exception when getting component's update time : Unable to retrieve component's update time : expected 1 columns in select list but found 11
the SQLJ command corresponding => #sql { SELECT TO_CHAR(UPDATE_TIME, 'DD/MM/YYYY HH24:MI:SS') INTO :updateTime FROM COMPONENT WHERE COMPONENT_NAME = :componentName };
with SQL*plus no problems to have a result, more is that we have only 3 distinct columns, so why 11 ????
Is anyone had already these kinds of troubleshootings ???
Here is my environment :
- HP-UX B.11.00 U 9000/785 (64 bits)
- Oracle SQLJ Release 9.2.0.3.0 Production
Copyright © 1997, 2003, Oracle Corporation. All Rights Reserved.
Build version: 2.3.0.0 - Built on Feb 15, 2002
IDE interface version: 9.2.0.3.0/2.3.0.0
JDBC version: Oracle JDBC driver version 9.2 (9.2.0.3.0)
SQLJ runtime: Oracle 9.2.0 for JDBC 8.1.7 or later/JDK 1.2.x - Built on Jul 21, 2003
Java version: 1.4 (1.4.2.00)
ChrisChris,
The error messages are misleading. I'm only guessing, but from what you have posted, it looks like the problem is in the values you are supplying for your bind variables. It could be that the SQL parser thinks that a bind variable is a column name -- and, of-course, there is no such column name, hence the "Invalid column name" error. Do you know about P6Spy ? It captures the SQL with the bind variable values, so you see the exact SQL that is getting sent to Oracle.
Good Luck,
Avi. -
Sqlj.runtime package missing
Two questions:
1) JDeveloper 3.1 is not able to locate sqlj.runtime and it's there, it was working properly a 15 minutes ago. Any suggestion?
2) what does the following warning message mean?
Warning: (33) Type driverTest.Driver of host item #1 is not permitted in JDBC. This will not be portable..
Thanks in advance!!
The whole error message I got from JDev:
D:\Program Files\Oracle\JDeveloper 3.1\myprojects\driverTest\mydriver.sqlj
Warning: (33) Type driverTest.Driver of host item #1 is not permitted in JDBC. This will not be portable..
Error: (4) identifier sqlj.runtime.ref.DefaultContext not found.
Error: (5) identifier sqlj.runtime.ConnectionContext not found.
Error: (20) class ConnectionContext not found in class driverTest.mydriver.
Error: (11) identifier sqlj.runtime.ref.ConnectionContextImpl not found.
Error: (11) identifier sqlj.runtime.ConnectionContext not found.
Error: (0) identifier sqlj.runtime.profile.Loader not found.
Error: (17) variable DefaultContext not found in class driverTest.mydriver.
Error: (17) constructor mydriver$_Ctx(<any>) not found in class driverTest.mydriver._Ctx.
Error: (22) constructor mydriver$_Ctx(<any>) not found in class driverTest.mydriver._Ctx.
Error: (26) constructor mydriver$_Ctx(java.sql.Connection) not found in class driverTest.mydriver._Ctx.
Error: (33) identifier sqlj.runtime.ConnectionContext not found.
Error: (33) identifier sqlj.runtime.error.RuntimeRefErrors not found.
Error: (33) identifier sqlj.runtime.ExecutionContext not found.
Error: (33) identifier sqlj.runtime.error.RuntimeRefErrors not found.
Error: (33) identifier sqlj.runtime.profile.RTStatement not found.
Error: (0) identifier sqlj.runtime.RuntimeContext not found.
Error: (0) method getProfileKey(<any>, java.lang.String) not found in class driverTest.mydriver._Ctx.
D:\Program Files\Oracle\JDeveloper 3.1\myprojects\driverTest\Driver.sqlj
Error: (11) identifier sqlj.runtime.ref.DefaultContext not found.
Error: (12) identifier sqlj.runtime.ConnectionContext not found.
Error: (52) class ConnectionContext not found in class driverTest.Driver.
Error: (20) identifier sqlj.runtime.ref.ConnectionContextImpl not found.
Error: (20) identifier sqlj.runtime.ConnectionContext not found.
Error: (44) variable DefaultContext not found in class driverTest.Driver.
Error: (44) constructor Driver$_Ctx(<any>) not found in class driverTest.Driver._Ctx.
Error: (55) variable DefaultContext not found in class driverTest.Driver.
Error: (55) constructor Driver$_Ctx(<any>) not found in class driverTest.Driver._Ctx.
Error: (61) constructor Driver$_Ctx(java.sql.Connection) not found in class driverTest.Driver._Ctx.
Error: (67) constructor Driver$_Ctx(oracle.jdbc.driver.OracleConnection) not found in class driverTest.Driver._Ctx.
Error: (77) constructor Driver$_Ctx(oracle.jdbc.driver.OracleConnection) not found in class driverTest.Driver._Ctx.
D:\Program Files\Oracle\JDeveloper 3.1\myhtml\driverTest_html\view.jsp
Error: (27) incompatible types; found: void, required: driverTest.Driver.
null1) JDeveloper 3.1 is not able to locate sqlj.runtime Ensure that the SQLJ runtime.zip and/or translator.zip file is in the project's CLASSPATH.
2) Warning: (33) Type driverTest.Driver of host item #1 is not permitted in JDBC. 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'd only care about this warning if you want to write fully portable code. You can turn of portability warnings in JDeveloper under project properties on the SQLJ tab. On the SQLJ command line you could say: -warn=noportable. -
Hi:
I am getting the following Exception when I call sqlj based java class from a jsp page. The Exception indicates that the SQLJ runtime tries to grab the sql statement from the cache, but it is going out of the Arrary bounds. I am really wondering if clearing SQLJ cache will resolve the issue. If it does, how can I clear the SQLJ runtine cache on Solaris 7.
Your help is very much appreciated, as I wasted long time trying to debug it.
java.lang.ArrayIndexOutOfBoundsException: 63
at sqlj.runtime.profile.ref.StatementCacheProfile.getStatement(StatementCacheProfile.java:82)
at sqlj.runtime.profile.ref.ProfileWrapper.getStatement(ProfileWrapper.java:96)
at sqlj.runtime.ExecutionContext$StatementStack.setStatement(ExecutionContext.java:995)
at sqlj.runtime.ExecutionContext.registerStatement(ExecutionContext.java:523)
at com.nortelnetworks.productsupportability.sqlj.generated.passport.dpngate.getDefaultT1(dpngate.java:2405)
at netrx.charts._passport._dpngate._jspService(_dpngate.java:239)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
at oracle.jsp.JspServlet.internalService(JspServlet.java)
at oracle.jsp.JspServlet.service(JspServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:536)
RegardsAny one of the three following things should help:
(1) Add the generated .ser file(s) to be loaded by loadjava.
(2) Use the -ser2class option when translating your SQLJ source and add the additional .class files to be loaded by loadjava.
(3) Use loadjava to load SQLJ source rather than .class (and .ser) files. -
I would like to retrieve data from Oracle8.0.5 using sqlj.
i tried:
<%@page language="sqlj
import= sqlj.runtime.ref.DefaultContext,oracle.sqlj.runtime.Oracle"%>
and i've got the error:
java.lang.NoSuchMethodError: sqlj.tools.Sqlj: "method resetStaticVariables()V not found"
someone helps?
thanxThis uses a feature which is only found in post 8.1.6.1 versions of Oracle SQLJ. You have two choices:
(1) Download ojsp 1.0.0.6.1 or later from OTN. This contains an updated SQLJ version.
(2) Or wait for the SQLJ 8.1.7 release (or later) in the next couple of weeks.
null -
ClassNotFoundException:oracle.sqlj.runtime.Oracle
Sub: Error
message "ClassNotFoundException:oracle.sqlj.runtime.Oracle"
Hi,
I am trying to run an applet whose source is compiled by sqlj
with no errors. Applications hit the database and run fine from
the Sun Unix command prompt, but when I write as an applet and
try to run through the web I get the above error message. I am
running webserver 3.0 and Oracle 8 version on Sun E10K with ver
5.6, JDK 1.2.
Thanks in advance for your reply.
Ravi Nitta
nullRavi Nitta (guest) wrote:
: Sub: Error
: message "ClassNotFoundException:oracle.sqlj.runtime.Oracle"
: Hi,
: I am trying to run an applet whose source is compiled by sqlj
: with no errors. Applications hit the database and run fine from
: the Sun Unix command prompt, but when I write as an applet and
: try to run through the web I get the above error message. I am
: running webserver 3.0 and Oracle 8 version on Sun E10K with ver
: 5.6, JDK 1.2.
: Thanks in advance for your reply.
: Ravi Nitta
Ravi --
I think there was a problem with the 8.0.5 distribution, in
that the oracle.sqlj.runtime classes did not make it into
the runtime.zip file.
Just add the oracle.sqlj.runtime.* packages to the zip
(compression must be set to none).
Additionally, you can remove the packages sqlj.runtime.util
and oracle.sqlj.runtime.util - these only get used at
translate time, not at runtime.
(Alternatively, if you can say: sqlj -profile=false ...
and your program still runs, you can do that, and your
applet will not use the Oracle-specific SQLJ runtime.)
Of course, the runtime.zip and your JDBC driver's zip must be
distributed with the applet.
If you get a SecurityException, then the SQLJ runtime you are
using utilizes reflection, and you have the options outlined
in my other reply to your query.
Hope this helps.
-- Ekkehard
null -
I am running on an Oracle 8.1.5 database using SQLJ Release 8.1.5.0.0 and JDBC version 8.1 (8.1.5.0.0). My SQLJ program precompiles and compiles successfully, resulting in a .class file which I load without error using the loadjava utility. I then create a procedure to run the stored procedure. All this works just fine. However, when I run the procedure, I get the error:
"ORA-29541: class <class name> could not be resolved"
I can't find this error message documented anywhere. (I'm not saying it's not - I'm saying I can't find it.) This same process of loading .class files with loadjava and running them through a wrapper procedure works without errors for JDBC but not SQLJ. Any suggestions on how to fix this?Any one of the three following things should help:
(1) Add the generated .ser file(s) to be loaded by loadjava.
(2) Use the -ser2class option when translating your SQLJ source and add the additional .class files to be loaded by loadjava.
(3) Use loadjava to load SQLJ source rather than .class (and .ser) files. -
SQLJ Translation does not create profile file
SQLJ Translation does not create profile file.
After translating a small file HelloWorld.sqlj
the following files are created:
HelloWorld_SJProfileKeys.class
HelloWorld.class
HelloWorld.java
Although there is a HelloWorld_SJProfileKeys.class, profile file HelloWorld_SJProfile0.ser has NOT been created.
The starting file .sqlj file HelloWorld.sqlj is taken from O'Reilly book 'Java Programming with Oracle SQLJ' by Jason Price. The file contains a valid SQL statement to display the date.
My environment variables were set up with instructions from:
http://www.onjava.com/pub/a/onjava/2001/12/05/learning_sqlj.html
When I run java HelloWorld to run the .java file, I get the error:
SQLException java.sql.SQLException: profile HelloWorld_SJProfile0 not found: java.lang.ClassNotFoundException: HelloWorld_SJProfile0
I searched the internet high and low for a similar error to mine but I could not find a match.
I read the following text from http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#translationerrors
but it does not help me.
"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.
Any ideas? Thanks in advance,
John
Helloworld.sqlj before translation:
The program HelloWorld.sqlj illustrates how to connect to a
database, and display the words "Hello World" along with
the current date.
// import required packages
import java.sql.Date;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
public class HelloWorld {
public static void main(String [] args) {
java.sql.Date current_date;
try {
// connect to the database
Oracle.connect(
"jdbc:oracle:thin:@localhost:1521:orac",
"scott",
"tiger"
// get the current date from the database
#sql { SELECT sysdate INTO :current_date FROM dual };
// display message
System.out.println("Hello World! The current date is " +
current_date);
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} finally {
try {
// disconnect from the database
Oracle.close();
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} // end of main()
HelloWorld.java after translation:
/*@lineinfo:filename=HelloWorld*//*@lineinfo:user-code*//*@lineinfo:1^1*//*
The program HelloWorld.sqlj illustrates how to connect to a
database, and display the words "Hello World" along with
the current date.
// import required packages
import java.sql.Date;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
public class HelloWorld {
public static void main(String [] args) {
java.sql.Date current_date;
try {
// connect to the database
Oracle.connect(
"jdbc:oracle:thin:@localhost:1521:orcl",
"scott",
"tiger"
// get the current date from the database
/*@lineinfo:generated-code*//*@lineinfo:28^7*/
// #sql { SELECT sysdate FROM dual };
sqlj.runtime.profile.RTResultSet __sJT_rtRs;
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_CONN_CTX();
sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext();
if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX();
synchronized (__sJT_execCtx) {
sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, HelloWorld_SJProfileKeys.getKey(0), 0);
try
sqlj.runtime.profile.RTResultSet __sJT_result = __sJT_execCtx.executeQuery();
__sJT_rtRs = __sJT_result;
finally
__sJT_execCtx.releaseStatement();
try
sqlj.runtime.ref.ResultSetIterImpl.checkColumns(__sJT_rtRs, 1);
if (!__sJT_rtRs.next())
sqlj.runtime.error.RuntimeRefErrors.raise_NO_ROW_SELECT_INTO();
current_date = __sJT_rtRs.getDate(1);
if (__sJT_rtRs.next())
sqlj.runtime.error.RuntimeRefErrors.raise_MULTI_ROW_SELECT_INTO();
finally
__sJT_rtRs.close();
/*@lineinfo:user-code*//*@lineinfo:28^58*/
// display message
System.out.println("Hello World! The current date is " +
current_date);
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} finally {
try {
// disconnect from the database
Oracle.close();
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} // end of main()
}/*@lineinfo:generated-code*/class HelloWorld_SJProfileKeys
private static HelloWorld_SJProfileKeys inst = null;
public static java.lang.Object getKey(int keyNum)
throws java.sql.SQLException
if (inst == null)
inst = new HelloWorld_SJProfileKeys();
return inst.keys[keyNum];
private final sqlj.runtime.profile.Loader loader = sqlj.runtime.RuntimeContext.getRuntime().getLoaderForClass(getClass());
private java.lang.Object[] keys;
private HelloWorld_SJProfileKeys()
throws java.sql.SQLException
keys = new java.lang.Object[1];
keys[0] = sqlj.runtime.ref.DefaultContext.getProfileKey(loader, "HelloWorld_SJProfile0");
}SQLJ Translation does not create profile file.
After translating a small file HelloWorld.sqlj
the following files are created:
HelloWorld_SJProfileKeys.class
HelloWorld.class
HelloWorld.java
Although there is a HelloWorld_SJProfileKeys.class, profile file HelloWorld_SJProfile0.ser has NOT been created.
The starting file .sqlj file HelloWorld.sqlj is taken from O'Reilly book 'Java Programming with Oracle SQLJ' by Jason Price. The file contains a valid SQL statement to display the date.
My environment variables were set up with instructions from:
http://www.onjava.com/pub/a/onjava/2001/12/05/learning_sqlj.html
When I run java HelloWorld to run the .java file, I get the error:
SQLException java.sql.SQLException: profile HelloWorld_SJProfile0 not found: java.lang.ClassNotFoundException: HelloWorld_SJProfile0
I searched the internet high and low for a similar error to mine but I could not find a match.
I read the following text from http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#translationerrors
but it does not help me.
"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.
Any ideas? Thanks in advance,
John
Helloworld.sqlj before translation:
The program HelloWorld.sqlj illustrates how to connect to a
database, and display the words "Hello World" along with
the current date.
// import required packages
import java.sql.Date;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
public class HelloWorld {
public static void main(String [] args) {
java.sql.Date current_date;
try {
// connect to the database
Oracle.connect(
"jdbc:oracle:thin:@localhost:1521:orac",
"scott",
"tiger"
// get the current date from the database
#sql { SELECT sysdate INTO :current_date FROM dual };
// display message
System.out.println("Hello World! The current date is " +
current_date);
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} finally {
try {
// disconnect from the database
Oracle.close();
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} // end of main()
HelloWorld.java after translation:
/*@lineinfo:filename=HelloWorld*//*@lineinfo:user-code*//*@lineinfo:1^1*//*
The program HelloWorld.sqlj illustrates how to connect to a
database, and display the words "Hello World" along with
the current date.
// import required packages
import java.sql.Date;
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
public class HelloWorld {
public static void main(String [] args) {
java.sql.Date current_date;
try {
// connect to the database
Oracle.connect(
"jdbc:oracle:thin:@localhost:1521:orcl",
"scott",
"tiger"
// get the current date from the database
/*@lineinfo:generated-code*//*@lineinfo:28^7*/
// #sql { SELECT sysdate FROM dual };
sqlj.runtime.profile.RTResultSet __sJT_rtRs;
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_CONN_CTX();
sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext();
if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX();
synchronized (__sJT_execCtx) {
sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, HelloWorld_SJProfileKeys.getKey(0), 0);
try
sqlj.runtime.profile.RTResultSet __sJT_result = __sJT_execCtx.executeQuery();
__sJT_rtRs = __sJT_result;
finally
__sJT_execCtx.releaseStatement();
try
sqlj.runtime.ref.ResultSetIterImpl.checkColumns(__sJT_rtRs, 1);
if (!__sJT_rtRs.next())
sqlj.runtime.error.RuntimeRefErrors.raise_NO_ROW_SELECT_INTO();
current_date = __sJT_rtRs.getDate(1);
if (__sJT_rtRs.next())
sqlj.runtime.error.RuntimeRefErrors.raise_MULTI_ROW_SELECT_INTO();
finally
__sJT_rtRs.close();
/*@lineinfo:user-code*//*@lineinfo:28^58*/
// display message
System.out.println("Hello World! The current date is " +
current_date);
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} finally {
try {
// disconnect from the database
Oracle.close();
} catch ( SQLException e ) {
System.err.println("SQLException " + e);
} // end of main()
}/*@lineinfo:generated-code*/class HelloWorld_SJProfileKeys
private static HelloWorld_SJProfileKeys inst = null;
public static java.lang.Object getKey(int keyNum)
throws java.sql.SQLException
if (inst == null)
inst = new HelloWorld_SJProfileKeys();
return inst.keys[keyNum];
private final sqlj.runtime.profile.Loader loader = sqlj.runtime.RuntimeContext.getRuntime().getLoaderForClass(getClass());
private java.lang.Object[] keys;
private HelloWorld_SJProfileKeys()
throws java.sql.SQLException
keys = new java.lang.Object[1];
keys[0] = sqlj.runtime.ref.DefaultContext.getProfileKey(loader, "HelloWorld_SJProfile0");
} -
Oracle SQLJ not working in WebLogic
Mybe its a little off topic here, but the JDBC and SQLJ runtime comes with JDeveloper.
I try to deploy my application to WebLogic 7.0.0.1 and cannot get SQLJ code running.
I loaded all jars (JDBC: classes12.jar, nls_charset12.jar; SQLJ: runtime12.jar) to the server. The driver of the connection reports version "Oracle JDBC driver 9.0.1.4".
Here is the exception stack:
java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso or with -codegen=jdbc. at sqlj.runtime.ref.ConnectionContextImpl.getOracleConnection(ConnectionContextImpl.java:146) at sqlj.runtime.ExecutionContext$OracleContext.prepareOracleCall(ExecutionContext.java:1517)
Next I`m going to try translating with codegen=jdbc as workaround. But then I cannot use any Oracle specific enhancements.
Thanks for any help,
RobertI'm not sure off-hand what the solution is. You may want to try the SQLJ/JDBC forum if you haven't already.
-- Brian -
Sqlj fails with call to raise_application_error
I get an error
Invoking loadjava on connection 'dbm1_twebn1' with arguments:
-order -resolve -thin -verbose
creating : class SystemDaemon/testcase
loading : class SystemDaemon/testcase
resolving: class SystemDaemon/testcase
errors : class SystemDaemon/testcase
ORA-29521: referenced name sqlj/runtime/ExecutionContext$OracleContext could not be found
The following operations failed
class SystemDaemon/testcase: resolution
when I load this sqlj file
in an 8.1.7 database
package SystemDaemon;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
import java.sql.*;
import oracle.sqlj.runtime.*;
public class testcase
static public void testcase1()
String s = new String("this is a test");
try
#sql {CALL RAISE_APPLICATION_ERROR(-20020, :s)};
catch (SQLException e)
// putLine("error in raise_application_error" + e.getMessage());
This works fine in a 9i database
I get other errors when i load the source code into the database but I get thoses in both 8i and 9i.
any sugestions on how to fix this?
Daniel Smith
[email protected]It appears that you are translating SQLJ using the 9i version of the SQLJ
translator and loading that into an 8i database. The SQLJ code that
is generated by default requires a 9i (or later) version of the SQLJ runtime
and JDBC driver as well. The 8i database only has the 8i SQLJ runtime available to it.
You can turn on backwords compatibility for your SQLJ code with the option:
-codegen=iso
This generates standard SQLJ code (including .ser files that contain the code
of your SQLJ statements) that can be used in 8i as well as in 9i - just make
sure you load both, .ser and .class files into the database (or use the
-ser2class option to convert .ser into .class files). Or, just load the source
directly into the database.
Please note an additional caveat when generating code with SQLJ. If you
translate code with the 9.0.1 JDBC driver in the CLASSPATH, then this
code will run under 9.0.1 and later (such as 9.2) JDBC drivers. However,
the converse is not true: if you use a 9.2 JDBC driver during translation,
the generated code will utilize 9.2-specific JDBC APIs and may not run
under 9.0.1 JDBC. Thus to get compatibility: either use the -codegen=iso
option, or make sure that when your code is run you use the same or
a later JDBC driver than what you used when the code was translated.
Hope this helps.
-- Ekkehard -
[SQLJ] Context Problem
Hi all,
I am working on Oracle 9i and I compile with the Oracle Console Entreprise Manager.
From an instance baseA, I am looking for getting values from other instance baseB :
Code :
DefaultContext connB = Oracle.getConnection("jdbc:oracle:thin:@ipServer:1521:baseB","user","pwd");
DefaultContext connA = Oracle.getConnection("jdbc:oracle:thin:@ipServer:1521:baseA","user","pwd");
try {
String result = "";
#sql [[connB ]] { SELECT lib INTO :result FROM TAB_MESURE WHERE id = 4 };
RETURN result;
finally {
connB.close();
connA.close();
When compiling, this error is displayed
Warning: Impossible de vérifier la clause WHERE. Erreur renvoyée par la base de données : ORA-00942: Table ou vue inexistante (french)
ORA-00942: Table or view doest not exist
- all tns are corectly set up
- Within the same instance,all requests are OK (without using of context)
- I tried diferent connection method wothout success (Oracle.connect, DefaultContext.setDefaultContext, )
Thanks for your help
Merci pour votre aide
Edited by: user11166064 on 14 mai 2009 02:41
Edited by: user11166064 on 14 mai 2009 02:49Ok,
So i re-formulate my request, here the acual code executed :
h5. 1- Java code :
import java.sql.*;
import sqlj.runtime.ref.DefaultContext;
import oracle.sqlj.runtime.Oracle;
import sqlj.runtime.ExecutionContext;
#sql iterator MyIter2 (Integer elt_id, String elt_lst_code, String elt_lib, Integer elt_actif);
public class TestInsert {
public static void test() throws Exception {
DefaultContext connB = Oracle.getConnection("jdbc:oracle:thin:@ipServer:1521:baseB","user","pwd");
DefaultContext connA = Oracle.getConnection("jdbc:oracle:thin:@ipServer:1521:baseA","user","pwd");
MyIter2 iter;
Integer ident;
String listCode;
String lib;
String actif;
try {
#sql [[connB]] iter={ select elt_id, elt_lst_code, elt_lib, elt_actif from baseB.<user>.ELT elt_elt_id is NULL };
while (iter.next()) {
ident = iter.elt_id();
listCode = iter.elt_lst_code();
lib = iter.elt_lib();
actif = String.valueOf(iter.elt_actif());
#sql [connA]] { insert into BIBLIO_0 (ID, LIBELLE) values (:ident, :lib) };
#sql [[connA]] { COMMIT};
} finally {
connB.close();
connA.close();
h5. 2- Loadjava
loadjava -u user/pwd@connA -v -resolve TestInsert.java
it returns a warning :
Impossible to check SQL instruction
+#sql [connB] iter={ select elt_id, elt_lst_code, elt_lib, elt_actif from baseB.<user>.ELT elt_elt_id is NULL };+
h5. 3- Create and execute stored procedure
I connect to baseA through sql*plus and execute the command :
CREATE OR REPLACE PROCEDURE SP_TESTINSERT AS LANGUAGE JAVA NAME 'TestInsert.test()';
EXECUTE SP_TESTINSERT;
I've got the errors :
ORA-29532: java call terminated by uncaught java exception :
java.sql.SQLException: ORA-00903: invalid table name
ORA-06512: at "BASEB.TESTINSERT", ligne 0
ORA-06512: at ligne 1
I've changed :
+#sql [[connB]] iter={ select elt_id, elt_lst_code, elt_lib, elt_actif from baseB.<user>.ELT elt_elt_id is NULL };+
to
+#sql [[connB]] iter={ select elt_id, elt_lst_code, elt_lib, elt_actif <user>.ELT elt_elt_id is NULL };+
but during the compilation (loadjava) I have :
ORA-29535: source requires recompilation
TestInsert:23: Impossible to check SQL interrogation. ORA-00903: invalid table name
#sql [connGeochim] iter={ select elt_id, elt_lst_code, elt_lib, elt_actif from
<user>.ELT elt_elt_id is NULL };
^
<no file>: Processing source TestInsert encountered sqlj translation failed.
Info: 2 errors
The following operations failed
source TestInsert: resolution
exiting : Failures occurred during processing
thanks -
SQLJ classes (Will not insert result into table)
/*@lineinfo:filename=SqljCircle*//*@lineinfo:user-code*//*@lineinfo:1^1*/import java.sql.SQLException ;
import oracle.sqlj.runtime.Oracle;
// iterator for the select
/*@lineinfo:generated-code*//*@lineinfo:5^1*/
// SQLJ iterator declaration:
class myIter
extends sqlj.runtime.ref.ResultSetIterImpl
implements sqlj.runtime.NamedIterator
public myIter(sqlj.runtime.profile.RTResultSet resultSet)
throws java.sql.SQLException
super(resultSet);
RadiusNdx = findColumn("Radius");
public int Radius()
throws java.sql.SQLException
return resultSet.getIntNoNull(RadiusNdx);
private int RadiusNdx;
/*@lineinfo:user-code*//*@lineinfo:5^33*/
class SqljCircle
//Main method
public static void main (String args[])
try {
// set the default connection to the URL, user, and password
// specified in your connect.properties file
Oracle.connect(SqljCircle.class, "connect.properties");
SqljCircle ti = new SqljCircle();
ti.runExample();
} catch (SQLException e) {
System.err.println("Error running the example: " + e);
} //End of method main
//Method that runs the example
void runExample() throws SQLException
myIter iter;
/*@lineinfo:generated-code*//*@lineinfo:28^1*/
// #sql iter = { select radius from RADIUS_VALS };
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_CONN_CTX();
sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext();
if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX();
synchronized (__sJT_execCtx) {
sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SqljCircle_SJProfileKeys.getKey(0), 0);
try
sqlj.runtime.profile.RTResultSet __sJT_result = __sJT_execCtx.executeQuery();
iter = new myIter(__sJT_result);
finally
__sJT_execCtx.releaseStatement();
/*@lineinfo:user-code*//*@lineinfo:28^45*/
while (iter.next()) {
// To see the radius values:
System.out.println(iter.Radius());
int radInput = iter.Radius();
double result=area(radInput);
// To see the result values:
System.out.println(result);
/*@lineinfo:generated-code*//*@lineinfo:38^1*/
//#sql { insert into RADIUS_VALS values(:radInput,:result) };
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_CONN_CTX();
sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext();
if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX();
int __sJT_1 = radInput;
double __sJT_2 = result;
synchronized (__sJT_execCtx) {
sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SqljCircle_SJProfileKeys.getKey(0), 1);
try
__sJT_stmt.setInt(1, __sJT_1);
__sJT_stmt.setDouble(2, __sJT_2);
__sJT_execCtx.executeUpdate();
finally
__sJT_execCtx.releaseStatement();
/*@lineinfo:user-code*//*@lineinfo:38^51*/
/*@lineinfo:generated-code*//*@lineinfo:39^1*/
//#sql { commit };
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_CONN_CTX();
sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext();
if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX();
synchronized (__sJT_execCtx) {
sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SqljCircle_SJProfileKeys.getKey(0), 2);
try
__sJT_execCtx.executeUpdate();
finally
__sJT_execCtx.releaseStatement();
/*@lineinfo:user-code*//*@lineinfo:39^13*/
iter.close();
// Utility function to calculate the area
public static double area (int rad) {
double pi=3.1415926;
double areacircle=pi*rad*rad;
return areacircle;
}/*@lineinfo:generated-code*/class SqljCircle_SJProfileKeys
private static SqljCircle_SJProfileKeys inst = null;
public static java.lang.Object getKey(int keyNum)
throws java.sql.SQLException
if (inst == null)
inst = new SqljCircle_SJProfileKeys();
return inst.keys[keyNum];
private final sqlj.runtime.profile.Loader loader = sqlj.runtime.RuntimeContext.getRuntime().getLoaderForClassT(getClass());
private java.lang.Object[] keys;
private SqljCircle_SJProfileKeys()
throws java.sql.SQLException
keys = new java.lang.Object[1];
keys[0] = sqlj.runtime.ref.DefaultContext.getProfileKey(loader, "SqljCircle_SJProfile0");
This SQLJ class compiles and runs ok, it retrieves a number from a table in my database, computes the result and prints them both out but it will not insert the result back into a table in my database, WHY????
Philip.Thanks a million to all of you, the final working code;
Zed
<%
String name = request.getParameter("name");
String connectionURL = "jdbc:mysql://localhost:3306/";
String dbName = "test";
String userName = "root";
String password = "";
Connection connection = null;
PreparedStatement pstatement = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
try {
connection = DriverManager.getConnection(connectionURL+dbName,userName,password);
String queryString = "INSERT INTO employees(id, name) VALUES (id, " + "'" + name + "'" + ")";
pstatement = connection.prepareStatement(queryString);
pstatement.executeUpdate(queryString);
catch (Exception ex) {
out.println("Error = " + ex.toString());
pstatement.close();
connection.close();
%> -
Sqlj TestInstallSQLJ.sqlj
Trying to translate this sample code brougt the following error:
unexpected error occurred...
java.lang.NoSuchMethodError: sqlj.runtime.profile.ref.EntryInfoImpl.<init>(Ljava
/lang/String;IIIILjava/lang/Object;[Lsqlj/runtime/profile/TypeInfo;[Lsqlj/runtim
e/profile/TypeInfo;ILjava/lang/String;)V
at sqlj.codegen.ProfileDecl$EntryInit.getEntryInfo(ProfileDecl.java:131)
at sqlj.codegen.ProfileDecl.getProfile(ProfileDecl.java:75)
at sqlj.codegen.ExecCodegen$ProfileParselet.generate(ExecCodegen.java:581)
at sqlj.javac.ASTCompilationUnit.generate(ASTCompilationUnit.java:218)
at sqlj.translator.Translator.translate(Translator.java:257)
at sqlj.translator.Translator.translate(Translator.java:228)
at sqlj.translator.Main.translate(Main.java:124)
at sqlj.translator.Main.runTranslation(Main.java:99)
at sqlj.translator.Main.runTranslation(Main.java:92)
at sqlj.tools.Sqlj.statusMain(Sqlj.java:294)
at sqlj.tools.Sqlj.main(Sqlj.java:136)
Error: Exception caught:
Total 1 error.
In the classpath I have the runtime12ee.jar and translator.zip. Am I possibly missig something?
I would appreciate every answer!Please see:
http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#exceptionininitializer
Note that you can also download the 8.1.6SDK patch for your command line version of SQLJ - just replace translator.zip with the one from the patch.
If this does not fit your problem then you need to provide more information. Please check out:
http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#checklist
null -
NoSuchfieldName error while compiling a class that was produced by sqlj
hello all,
could you please tell me where the following error code came from when i
tried to execute java TestInstallSQLJ?
I could use sqlj TestInstallSQLJ.sqlj to translate it into java code, but
then....
thank you for your help.
Exception in thread "main" java.lang.NoSuchFieldError
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Error.<init>(Error.java:50)
at java.lang.LinkageError.<init>(LinkageError.java:43)
at
java.lang.IncompatibleClassChangeError.<init>(IncompatibleClassChangeError.java:43)
at java.lang.NoSuchFieldError.<init>(NoSuchFieldError.java:45)
at
oracle.sqlj.runtime.OraDynamicClosure.getSQLType(OraDynamicClosure.java:68)
at
oracle.sqlj.runtime.OraBasicClosure.<init>(OraBasicClosure.java:47)
at
oracle.sqlj.runtime.OraClosureFactory.addStandardTypes(OraClosureFactory.java:138)
at
oracle.sqlj.runtime.OraClosureFactory.get81Closures(OraClosureFactory.java:50)
at
oracle.sqlj.runtime.OraClosureFactory.getTypeClosures(OraClosureFactory.java:33)
at
oracle.sqlj.runtime.OraCustomization.getProfile(OraCustomization.java:95)
at
oracle.sqlj.runtime.OraCustomization.getProfile(OraCustomization.java:87)
at sqlj.runtime.profile.ref.ProfileImpl.getConnectedProfile(Compiled
Code)
at
sqlj.runtime.ref.ProfileGroup$ConnectedGroup.getProfile(ProfileGroup.java:154)
at
sqlj.runtime.ref.ConnectionContextImpl.getConnectedProfile(ConnectionContextImpl.java:183)
at
sqlj.runtime.ExecutionContext.registerStatement(ExecutionContext.java:279)
at TestInstallSQLJ.runExample(Compiled Code)
at TestInstallSQLJ.main(TestInstallSQLJ.java:56)following is my environment:
sqlj -version-long
Oracle SQLJ Release 8.1.6.0.0 - SDK
Build version: 1.0.4.4 - Built on Apr 14, 1999
IDE interface version: 8.1.6.0.0/1.0.4.4
JDBC version: non Oracle driver version 0.0 (0.0.0.0)
java -version
java version "1.2.1"
Solaris VM (build Solaris_JDK_1.2.1_03, native threads, sunwjit)
echo $PATH
a long path +
/examples/sqlj/bin
echo $CLASSPATH
a long CLASSPATH +
/examples/sqlj/lib/translator.zip:
oracle JDBC driver8.1.7
it translated my sqlj files but then it can't interprete my java classes.
thank you a lot for your help
Maybe you are looking for
-
I display an animated gif on form submit Chrome, safari and opera all continue to animate the gif while the new page is loading. I use the javascript window.location = 'http://...' to load the new page
-
Connected.. then OK to disconnect. identified by windows but not itunes
By this point i am very fed up with apple, my ipod, and itunes. I have had this problem since i first bought my ipod nano3g 8gb. I have windows xp, my itunes is updated and this problem persists with all 3 usb ports on my computer. when i plug in my
-
How to apply outbound link tracking code in Adobe Muse?
Using Adobe Muse v6 to build my website and want to set up outbound URL tracking on a number of links. I have the correct code snippets from https://support.google.com/analytics/answer/1136920?hl=en <script type="text/javascript"> function trackOutbo
-
Apple TV not showing up in Display options
I have a 3rd generation Apple TV and a 2012 Mac Mini. As far as I can tell this should work and it did work before I upgraded to Yosemite (today was the first time since then that I tried to connect the two). As you can see, no Devices are Detected
-
This is LakshmiNarayana Chowdary.N. I'm Working with Sap NetWaver WebDynpro.. I Want To Retrieve Contents Of An Excel File Into Char[] Or Byte[] In JAVA Could Anybody Help Me Plz Thanks In Advancce