Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Java stored procedure problem within Oracle8i/Java coding bug?
Up front I have cross-posted this to comp.lang.java.programmer and
comp.databases.oracle.server. Apologies. This is the problem part
of a huge Java application running from within an Oracle database
and I'm not sure whether this is a Java issue or an Oracle issue
and therefore where would be the most informative place to post.
Below is a Java code snippet wrapped up in a CREATE/REPLACE to
execute within Oracle. When I execute within an IDE [not from
within Oracle so it is running via main(), copy/paste the bits
between the CREATE OR REPLACE AND COMPILE .... and the '/' to
reproduce], I get the following printed out on the screen:
Class2$inner1$picC,Class2$inner1$picB,Class2$inner1$picA,
This is what the I expect and want. However when I execute as a Java stored procedure (from SQL/plus), I get the output:
SQL>
SQL> SELECT testRoutines.getClasses AS R1, testRoutines.getDummy R2
FROM DUAL;
R1 R2 ------------------------------------------- dummy SQL>
'Class2$inner1$picC,Class2$inner1$picB,Class2$inner1$picA,
showing up under the R1 column above. I'm stumped. And having said why, what "magic" can put it there?
Thank you all for thinking about this nastly little problem. David.
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Test" AS
public class Class2
{
private static class inner1
{
protected final picC c=new picC(this);
private static class picA{} private static class picB{} private static class picC{ private String _classNames=""; public picC(Object me){ Class[] classSet=me.getClass().getDeclaredClasses(); String classData=""; for(int i=0;i<classSet.length;i++) _classNames=_classNames+classSet[i].getName()+","; } public String getClassNames(){ return _classNames; } } public String getResult(){ return c.getClassNames(); }
public static String getDummyString(){
return "dummy";
}
public static String getClassNames(){
inner1 x=new inner1();
return x.getResult();
}
public static void main(String[] args){
System.out.println(getClassNames());
}
}
/
CREATE OR REPLACE PACKAGE testRoutines AS
FUNCTION getClasses RETURN VARCHAR2
IS LANGUAGE JAVA NAME 'Class2.getClassNames() return
java.lang.String';
FUNCTION getDummy RETURN VARCHAR2
IS LANGUAGE JAVA NAME 'Class2.getDummyString() return
java.lang.String';
END testRoutines;
/
SELECT testRoutines.getClasses AS R1, testRoutines.getDummy R2 FROM
DUAL;
SQL>
SQL> SELECT testRoutines.getClasses AS R1, testRoutines.getDummy R2
FROM DUAL;
R1 R2 ------------------------------------------- dummy SQL>
SQL> SQL> SQL> SELECT * FROM V$VERSION;
BANNER
SQL>
SQL>
C:\> C:\> C:\>java -version
1.3.1_06-b01)
Java HotSpot(TM) Client VM (build 1.3.1_06-b01, mixed mode)
C:\> Received on Thu Jan 23 2003 - 09:24:00 CST