Re: Java stored procedures questions
Date: Tue, 24 Aug 1999 18:42:58 GMT
Message-ID: <37c9e6b7.110590570_at_newshost.us.oracle.com>
A copy of this was sent to "Alex Murkes" <murkes_at_my-Deja.com> (if that email address didn't require changing) On Mon, 23 Aug 1999 15:37:05 -0700, you wrote:
>I have some questions regarding Oracle stored procedures written in Java.
>
>Here's a very simple test Java class i'm trying to load into the RDBMS:
>
>public class SPTest
>{
> static int num = 0;
>
> public static int getInt()
> {
> return num++;
> }
>}
>
>1) I get this error:
>$ loadjava -user <connect_string> SPTest.class
>Error while retrieving errors for SPTest
> ORA-00904: invalid column name
>
>loadjava: 1 errors
>
>Anyone know what's wrong? In something configured incorrectly?
>
loadjava is the script that fails, the SQL it performs is:
select dbms_java.shortname('hello/Hello') from dual;
The reason it returns ora-904 invalid column name is because the dbms_java
package wasn't run. You need to run javavm/install/initjvm.sql
after this you can load java into database.
This should have been installed if you selected the java server option when you created the database.
>2) Will Oracle "do the right thing" with the stored procedure above? In
>other words, is there persistency, do static variables keep their values
>across procedure invocations? Or does Oracle reload classes on every call
>to stored procedures?
>
the classes stay there, for example:
tkyte_at_8i> create or replace function GetInt return number
2 as language java
3 name 'SPTest.getInt() return int';
4 /
Function created.
tkyte_at_8i> select getint from all_users where rownum < 10;
GETINT
0 1 2 3 4 5 6 7 8
9 rows selected.
tkyte_at_8i> select getint from all_users where rownum < 10;
GETINT
9 10 11 12 13 14 15 16 17
9 rows selected.
tkyte_at_8i>
tkyte_at_8i> disconnect
Disconnected from Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
With the Partitioning and Java options
PL/SQL Release 8.1.5.0.0 - Production
tkyte_at_8i> connect tkyte/tkyte
Connected.
tkyte_at_8i>
tkyte_at_8i> select getint from all_users where rownum < 10;
GETINT
0 1 2 3 4 5 6 7 8
9 rows selected.
>3) Assuming some persistency exists, does RMI work from Java stored
>procedures? Can I expose a persistent object to external processes through
>RMI?
>
cannot speak for RMI as i haven't used RMI but as sockets work just fine to achieve the above (i've done that) i don't see why not -- i just haven't tried it.
>Thanks!
>-Alex
>
>
>
>
-- See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA Opinions are mine and do not necessarily reflect those of Oracle CorporationReceived on Tue Aug 24 1999 - 20:42:58 CEST