| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> LoadJava et java stored proc
Hello,
I'm novice in oracle 9i release 2(Installed under XP professionnel) and
java technologies integrated in oracle.
Recently I've tried to load a java class in the JVM internal of oracle but It work partially...
1-My configuration and test environnement:
I'm sure that the environnement , the java interpretor, compilateur and
oracle works fines
I give you an example witch work fine
Instance oracle :TEST with predefined account scott/triger. I've configured the default environnement work of java.(Jsdk 1.3) CLASSPATH=C:\oracle\ora92\sqlj\lib\translator.jar;C:\oracle\ora92\sqlj\lib\r untime12.jar;c:\oracle\ora92\jdbc\lib\classes12.jar;
'--------------------------------------------------------------------------- ----------------
SalariesKPRB.java
--
import sqlj.runtime.ref.*;
import java.sql.*;
public class SalariesKPRB {
public SalariesKPRB() throws SQLException {}
public static String requete (int empId) throws SQLException {
String job;
String nom;
#sql {SELECT ENAME,JOB into :nom,:job from EMP where empno=:empId};
System.out.println("Nom du salarié #"+empId+" : "+nom);
System.out.println("Fonction du salarié #"+empId+" : "+job);
return new String("#"+empId+" : "+nom+" - "+job);
}
}
Sample compiled with sqlj pre-compilator and javac--> generate only
SalariesKPRB.class
(No message error)
then I load this class in the JVM of oracle:
loadjava -publish MyPackage -resolve -user scott/tiger_at_localhost: 1521:TEST
SalariesKPRB.class
in the oracle enterprise manager I can see as expected:
-->the wrapped function java in the package MyPackage
-->the function java in the source java and compiled class version (marked
as valid)
The sample witch don't work but I don't know why?
'---------------------------------------------------------------------------
-----------------
----------------------------------------------------------------------------
----------------
Salarie.java
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.*;
class Salarie
{
public static String getEmpGrade (int empid) throws SQLException
{
String nom=null;
Connection conn= null;
Statement stmt=null;
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn= DriverManager.getConnection("jdbc:oracle:kprb");
stmt=conn.createStatement();
ResultSet rset=stmt.executeQuery("SELECT JOB FROM EMP WHERE EMPNO="+empid);
while( rset.next())
{
nom=rset.getString(1);
}
}
finally
{
stmt.close();
return nom;
}
}
}
javac Salarie.java --> generate Salarie.class (no message error)
loadjava -publish MyPackage -resolve -user scott/tiger_at_localhost: 1521:TEST
Salarie.class
The first time i launch this line code It give me the message error:
The following operations failed
class Salarie: creation
exiting : Failures occurred during processing
In the oracle enterprise manager no object is created...
The second time, I lauc the same line code (in MSDOS command):
I've no message error and in the oracle enterprise manager in the java
classe of Schema Scott :
I'v the class Salarie marked as no-valid.
then I compiled class --> It marke valid.No Package is generated with
wrapper.
If someone has idea or a suggestion?
Received on Wed Jul 16 2003 - 11:50:12 CDT
![]() |
![]() |