Java stored procedures and referencing classes

We are referencing to some classes/libraries which are not present in the database. In normal java world, you specify the libraries/classes needed to run your piece of code in the CLASSPATH and that forms part of your complete code.
Can java stored procedures in the database refer to libraries or class files it requires on the file system rather than the database? Is it possible to make this happen?
Thanks

pshiva,
Posting the same question to multiple forums usually doesn't increase your chances of getting an answer, and it just frustrates those wishing to answer you with the result being that any future questions you post may have less chance of being answered -- because of your uncourteous, initial behaviour.
I have answered your other thread:
java stored procedures and referencing classes
In my opinion, that forum (the Database JVM forum) is the most appropriate for your question.
Good Luck,
Avi.

Similar Messages

  • Java stored procedures and triggers in lite

    Hi
    We are using java stored procedures and java triggers in our application for oracle lite database 5.1.
    We would like to know whether these procedures and triggers are uploaded or associated with tables or not because triggers are not being fired for the tables.
    The question is - how to find the uploaded procedures and triggers in system tables.
    We dont find any tables like (all_objects, user_objects) for this in oracle lite system catalogs given in the documentation.
    thanks in advance
    yugandhar

    I don't have much experience with Lite, but I'm running 9i Personal Edition. Any information about triggers can be found in the "ALL_TRIGGERS" view. You will want to filter out any rows where OWNER = 'SYS' unless you created your triggers as SYS. As for procedures and functions, you can see what you have created in the "ALL_OBJECTS" view where OBJECT_TYPE = 'PROCEDURE' or 'FUNCTION', once again filtering out rows where OWNER = 'SYS'. To see the code of any procedure or function, select substr(text,1,80) from ALL_SOURCE where NAME = 'function name' ORDER BY LINE.
    Hope this helps!

  • Java Stored Procedures and Triggers

    I want to to use Java stored procedures and triggers within the Oracle 11g XE
    So please , someone can help me because i tried but it didn't work
    I don't know where is the problem
    Thanks !!

    WRONG FORUM!
    Welcome to the forum but this forum is for Java JDBC questions and issues. Your question should be posted in the SQL and PL/SQL forum
    PL/SQL
    >
    I want to to use Java stored procedures and triggers within the Oracle 11g XE
    So please , someone can help me because i tried but it didn't work
    I don't know where is the problem
    >
    Mark this question ANSWERED and repost the question in the other forum
    Before you post review the Oracle Database Java Developer's Guide - it shows how to create Java stored procedures and has example code
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    And in the new post don't just say "I tried but it didn't work". You need to post the code that you tried and what you mean by "didn't work".
    If you got any exceptions or errors you need to post a copy of the exact message or error that you are getting.

  • Java Stored Procedures and Oracle XE

    Hi folks,
    Does anyone know if Oracle XE supports Java Stored Procedures.
    Thanks in advance,
    Kris

    Unfortunately you misunderstood me. I didn't call Oracle XE crippled, Yes, I did misunderstand. Apologies.
    Bottom line - JMS is not extant. JMS and AQ are not quite the same thing.
    AQ was developed back in early Oracle8 (8.0) (and possibly the late Oracle 7) days and seems to have been a pure PL/SQL implementation (probably with hooks at the C/C++ DB kernel level). The extensions that link to JMS came later.
    Since JMS depends on Java, and since 'Java in the database' is not part of XE by design and well documented, I considered you comment
    that JMS is not supported at all in Oracle XE or is at least
    severly crippled.to be more than you apparently meant it to be,
    AQ is 'supported' but lack of Java Stored Procs causes some limitations here as you have noted, as well as in Oracle Text and interMedia support.
    I'd love to see Java in the database for future upgrades to XE.

  • Java Stored Procedures and Sockets

    We need to synchronize data real time b/w Oracle and the legacy HP3000 system.
    For sending data from Oracle to HP3000 we are thinking of using Sockets.
    We dont know whether a socket connection can be established from the Oracle database level or need to be from the OS level(here Linux)
    I heard that Java stored procedures(JSP) can establish socket connection.
    Can someone provide me pointers regarding
    (a) setting up socket connection from the database
    (b) possibility of transferring data via sockets and using jdbc, and how to send data efficiently and if it is wise
    Thanks,
    Vinoj

    I don't have much experience with Lite, but I'm running 9i Personal Edition. Any information about triggers can be found in the "ALL_TRIGGERS" view. You will want to filter out any rows where OWNER = 'SYS' unless you created your triggers as SYS. As for procedures and functions, you can see what you have created in the "ALL_OBJECTS" view where OBJECT_TYPE = 'PROCEDURE' or 'FUNCTION', once again filtering out rows where OWNER = 'SYS'. To see the code of any procedure or function, select substr(text,1,80) from ALL_SOURCE where NAME = 'function name' ORDER BY LINE.
    Hope this helps!

  • Jdbc and java stored procedures

    Hi all,
    I am new to Oracle Java Stored Procedures but I am interested in knowing to which extent is object passing supported.
    Can I send any kind of object to a java stored procedure? And back from the procedure? Anybody knows any good resources online about Java Stored Procedures and JDBC?
    I also saw that to pass the string back you need to specify java.lang.string, how would I do in order to pass back a user defined object, do I have to register the class in Oracle before (and if yes, how?)or is the classpath enough?
    Many thanks,
    A.

    Hi again,
    perhaps I didn't understand exactly what you meant with "publish", AFAIK you have to expose the java class (i.e. RowCounter) by using
    CREATE OR REPLACE FUNCTION row_count (tab_name VARCHAR2) RETURN NUMBER
    AS LANGUAGE JAVA
    NAME 'RowCounter.rowCount(java.lang.String) return int';
    (BTW this works fine)
    or else you cannot access the java class you loaded on the server, and that's where my questions arose. What if I am passing an object, let's say myObject, shouldn't I use the STRUCT mapping then or something like that?
    Or, could you clarify what do you mean by publishing to SQL, I just need to access the class from jdbc, not from PL/SQL or others, but as I understand to call the class from JDBC I need to call the function or procedure that calls the class and then I could call it from PL/SQL as well...
    Thanks,
    A.

  • Publishing JSP form JAVA stored procedure [Oracle8i 8.1.7]

    Hi folks,
    I wonder if anybody knows a way to publish JSP from JAVA stored procedure.
    I know there is a way to load java class using PL/SQL package DBMS_JAVA.loadjava(), or
    oracle.aurora.server.tools.loadjava.LoadJavaMain.serverMain() from java.
    But I need somthing like publishjsp to translate the JSP.
    Also would be nice if I can invoke this from a LOB where I have stored my JSP.
    Any ideas?
    Mitko

    I case anyone is interested.
    I managed to find out what I was doing wrong.
    First when you call a stored procedure that is in a package and is a method of a class. You call it referencing the packagename.method. Leaving out the class name. Also, since this was a method that returns a value. The return value has to be assigned to a variable or used in an sql statement. Such as:
    var x number;
    call claimsprocedures.ip(19990033) into :x;call completed
    print x;(then the value is displayed in sql*plus
    scirco.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by scirco:
    I created a simple java stored procedure and depoloyed it using the deployment wizard. The code for the class is as follows:
    // Copyright (c) 2000 CAP-MPT
    package ClaimsProcedures;
    import sqlj.runtime.*;
    import sqlj.runtime.ref.*;
    import java.sql.*;
    import java.sql.SQLException;
    * A Sqlj class.
    * <P>
    * @author Sebastian Circo
    public class ClaimsFinancialHistory extends Object {
    * Constructor
    public ClaimsFinancialHistory() {
    public static int IP(int Claimno) throws SQLException {
    int Val;
    Val = 0;
    #sql {select sum(amount) into :Val from reshist
    where claimno = :Claimno and type = 'RI'};
    return Val;
    The wizard indicated that everything deployed properly. However when I try to call the procedure/method "IP" from sql*plus I get the following message: ORA-06576: not a valid function or procedure name. I double checked to make sure that I'm publishing the "IP" method and I still get the same error. I also tried calling the procedure with the schema.class.procedure form, still same error.
    Can anyone help?
    thanks
    scirco<HR></BLOCKQUOTE>
    null

  • Java stored procedures in 8.1.6

    I created a simple java stored procedure and depoloyed it using the deployment wizard. The code for the class is as follows:
    // Copyright (c) 2000 CAP-MPT
    package ClaimsProcedures;
    import sqlj.runtime.*;
    import sqlj.runtime.ref.*;
    import java.sql.*;
    import java.sql.SQLException;
    * A Sqlj class.
    * <P>
    * @author Sebastian Circo
    public class ClaimsFinancialHistory extends Object {
    * Constructor
    public ClaimsFinancialHistory() {
    public static int IP(int Claimno) throws SQLException {
    int Val;
    Val = 0;
    #sql {select sum(amount) into :Val from reshist
    where claimno = :Claimno and type = 'RI'};
    return Val;
    The wizard indicated that everything deployed properly. However when I try to call the procedure/method "IP" from sql*plus I get the following message: ORA-06576: not a valid function or procedure name. I double checked to make sure that I'm publishing the "IP" method and I still get the same error. I also tried calling the procedure with the schema.class.procedure form, still same error.
    Can anyone help?
    thanks
    scirco

    I case anyone is interested.
    I managed to find out what I was doing wrong.
    First when you call a stored procedure that is in a package and is a method of a class. You call it referencing the packagename.method. Leaving out the class name. Also, since this was a method that returns a value. The return value has to be assigned to a variable or used in an sql statement. Such as:
    var x number;
    call claimsprocedures.ip(19990033) into :x;call completed
    print x;(then the value is displayed in sql*plus
    scirco.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by scirco:
    I created a simple java stored procedure and depoloyed it using the deployment wizard. The code for the class is as follows:
    // Copyright (c) 2000 CAP-MPT
    package ClaimsProcedures;
    import sqlj.runtime.*;
    import sqlj.runtime.ref.*;
    import java.sql.*;
    import java.sql.SQLException;
    * A Sqlj class.
    * <P>
    * @author Sebastian Circo
    public class ClaimsFinancialHistory extends Object {
    * Constructor
    public ClaimsFinancialHistory() {
    public static int IP(int Claimno) throws SQLException {
    int Val;
    Val = 0;
    #sql {select sum(amount) into :Val from reshist
    where claimno = :Claimno and type = 'RI'};
    return Val;
    The wizard indicated that everything deployed properly. However when I try to call the procedure/method "IP" from sql*plus I get the following message: ORA-06576: not a valid function or procedure name. I double checked to make sure that I'm publishing the "IP" method and I still get the same error. I also tried calling the procedure with the schema.class.procedure form, still same error.
    Can anyone help?
    thanks
    scirco<HR></BLOCKQUOTE>
    null

  • Problem of java stored procedure

    hi,
    now I use the oracle9i JDeveloper9.0.3.1 to develop java stored procedure and then publish it to oracle9i database.
    In the database I create PL/SQL procedure to invoke the java stored procedure.But I encounter the problem,that is ,when I run the PL/SQL procedure ,it throw the java.lang.NullPointerException ,while the java class,the java stored procedure can run correctly invoked by the main class of java.The code of the java stored procedure is as follows:
    import java.sql.*;
    import java.util.Properties;
    public class SQLServerEventDistribute
    public static void sqlServerSaveData(String hostName,String databaseName,String user,String password,String tableName,int x1,int y1,int x2,int y2,String ip)
    String url="",sql="",userName="",passwd="";
    Connection connection;
    Statement statement;
    url="jdbc:microsoft:sqlserver://"+hostName+":1433;DatabaseName="+databaseName+";User="+user+";Password="+password;
    sql="INSERT INTO "+tableName+" VALUES("+x1+","+y1+","+x2+","+y2+",'"+ip+"')";
    Properties property=new Properties();
    property.setProperty(userName,user);
    property.setProperty(passwd,password);
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    // DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
    connection=DriverManager.getConnection(url,property);
    statement=connection.createStatement();
    statement.execute(sql);
    }catch(ClassNotFoundException connectSQLServerEx)
    System.out.println(connectSQLServerEx.getMessage());
    catch(SQLException connectSQLServerEx)
    System.out.println(connectSQLServerEx.getMessage()+connectSQLServerEx.getErrorCode());
    the main class is as follows:
    public class Test
    public static void main(String[] args)
    SQLServerEventDistribute.sqlServerSaveData("gsm","gsmd","sa","sa","IPBinding",11,45,24,21,"23.1.248.12");
    and the PL/SQL procedure is as follows:
    PROCEDURE TEST AS
    BEGIN
    SQLSERVERSAVEDATA('gsm','gsmd','sa','sa','IPBinding',11,45,24,21,'23.1.248.22');
    END;
    How can I deal with it?
    can you tell me?
    thanks

    Hi JavaQQ,
    This is just a guess, but I think you need to load the
    Micro$oft SQLServer JDBC driver into the Oracle
    database (using the "loadjava" utility).
    In any case, there are several ways -- apart from JDBC
    -- for accessing a different database from within an
    Oracle database. Have you tried searching the Oracle
    Web sites for suitable products?
    Hope this helps.
    Good Luck,
    Avi.abramia ,thank you very much.
    but I have load the Microsoft SQLServer JDBC driver into the Oracle database .
    When I debugged the PL/SQL procedure,the exception was thrown at line connection=DriverManager.getConnection(url,property);
    What's the problem with it?

  • Invoking "java myClass" using Runtime.Exec from a Java Stored Procedure

    Hi All,
    This is regarding the use of Runtime.getRunTime().exec, from a java programme (a Java Stored Procedure), to invoke another Java Class in command prompt.
    I have read many threads here where people have been successuful in invoking OS calls, like any .exe file or batch file etc, from withing Java using the Runtime object.
    Even i have tried a sample java programme from where i can invoke notepad.exe.
    But i want to invoke another command prompt and run a java class, basically in this format:
    {"cmd.exe","java myClass"}.
    When i run my java programme (in command prompt), it doesnt invoke another command prompt...it just stays hanging.
    When i run the java programme from my IDE, VisualCafe, it does open up a command prompt, but doesnt get the second command "java myCLass".
    Infact on the title of the command prompt (the blue frame), shows the path of the java.exe of the Visual Cafe.
    and anyway, it doesnt run my java class, that i have specified inside the programme.
    Even if i try to run a JAR file, it still doesnt do anything.
    (the JAR file other wise runs fine when i manually invoke it from the command prompt).
    Well, my question is, actually i want to do this from a Java Stored Procedure inside oracle 8.1.7.
    My feeling is, since the Java Stored Procedure wont be running from the command prompt (i will be actually invoking it through a Oracle trigger), it may be able to invoke the command prompt and run the java class i want. and that java class has to run with the SUn's Java, not Oracle JAva.
    Does any one have any idea about it?
    Has anyone ever invoked a java class or JAR file in command prompt from another Java Programme?
    YOur help will be highly appreciated.
    (P:S- Right now, my database is being upgraded, so i havent actually been able to create a Java Stored procedure and test it. But i have tested from a normal java programme running in command prompt and also from Visual Cafe).
    Thanks in advance.
    -- Subhasree.

    Hello Hari,
    Thanks for your quick reply.
    Can you please elaborate a little more on exactly how you did? may be just copy an dpaste taht part of teh code here?
    Thanks a lot in advance.
    --Subhasree                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java Stored Procedures with 9.2.0.5

    We are attempting to create Java Stored Procedures and we receive the following errors when attempting to do so, not sure why this is happening
    C:\WSADWorkspaces\siscore\siscoreCore\source\com\amfam\siscore\integration\service>loadjava -user sis_user/is3l
    l@aw0u -oci8 -resolve MaintainService.class
    Error while creating JAVA$CLASS$MD5$TABLE
    ORA-01031: insufficient privileges
    Error while getting old MD5 of com/amfam/siscore/integration/service/MaintainTigerService
    ORA-00942: table or view does not exist
    Error while creating CREATE$JAVA$LOB$TABLE
    ORA-01031: insufficient privileges
    Error while deleting com/amfam/siscore/integration/service/MaintainTigerService from lob table
    ORA-00942: table or view does not exist
    Error while loading class com/amfam/siscore/integration/service/MaintainTigerService
    ORA-00942: table or view does not exist
    Error while creating class com/amfam/siscore/integration/service/MaintainTigerService
    ORA-29506: invalid query derived from USING clause
    Error while deleting MD5 of com/amfam/siscore/integration/service/MaintainTigerService
    ORA-00942: table or view does not exist
    Error while deleting MD5 of com/amfam/siscore/integration/service/MaintainTigerService
    ORA-00942: table or view does not exist
    The following operations failed
    class com/amfam/siscore/integration/service/MaintainTigerService: creation
    exiting : Failures occurred during processing
    C:\WSADWorkspaces\siscore\siscoreCore\source\com\amfam\siscore\integration\service>

    Jay,
    You ned to grant user sis_user permission to load java classes into the database. Please refer to the Java Developer's Guide which is part of the Oracle documentation and can be accessed via:
    http://tahiti.oracle.com
    Good Luck,
    Avi.

  • Passing Tables back from Java Stored Procedures

    Thomas Kyte has written (in reference to
    trying to pass an array back from a stored
    function call):
    You can do one of two things (and both require the use of
    objects). You cannot use PLSQL table types as JDBC cannot bind to
    this type -- we must use OBJECT Types.
    [snip]
    Another way is to use a result set and "select * from
    plsql_function". It could look like this:
    ops$tkyte@8i> create or replace type myTableType as table of
    varchar2 (64);
    2 /
    Type created.
    ops$tkyte@8i>
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 function demo_proc2( p_rows_to_make_up in number )
    3 return myTableType
    4 as
    5 l_data myTableType := myTableType();
    6 begin
    7 for i in 1 .. p_rows_to_make_up
    8 loop
    9 l_data.extend;
    10 l_data(i) := 'Made up row ' &#0124; &#0124; i;
    11 end loop;
    12 return l_data;
    13 end;
    14 /
    Function created.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( demo_proc2(5) as mytableType )
    3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    Made up row 4 [Image]
    Made up row 5
    So, your JDBC program would just run the query to get the data.
    If the function "demo_proc2" cannot be called from SQL for
    whatever reason (eg: it calls an impure function in another piece
    of code or it itself tries to modify the database via an insert
    or whatever), you'll just make a package like:
    ops$tkyte@8i> create or replace package my_pkg
    2 as
    3
    4 procedure Make_up_the_data( p_rows_to_make_up in
    number ); 5 function Get_The_Data return myTableType;
    6 end;
    7 /
    Package created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace package body my_pkg
    2 as
    3
    4 g_data myTableType;
    5
    6 procedure Make_up_the_data( p_rows_to_make_up in number )
    7 as
    8 begin
    9 g_data := myTableType();
    10 for i in 1 .. p_rows_to_make_up
    11 loop
    12 g_data.extend;
    13 g_data(i) := 'Made up row ' &#0124; &#0124; i;
    14 end loop;
    15 end;
    16
    17
    18 function get_the_data return myTableType
    19 is
    20 begin
    21 return g_data;
    22 end;
    23
    24 end;
    25 /
    Package body created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( my_pkg.get_the_data as mytableType
    ) 3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    And you'll call the procedure followed by a query to get the
    data...
    I have tried this, and it works perfectly.
    My question, is what does the wrapper look
    like if the stored function is written
    in java instead of PL/SQL? My experiments
    with putting the function in java have been
    dismal failures. (I supposed I should also
    ask how the java stored procedure might
    look also, as I suppose that could be where
    I have been having a problem)
    null

    Thanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
    We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
    What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
    Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
    SELECT java_stored_proc(pl/sql_stored_proc(col_id))
    FROM table_of_5000_rows;
    Sorry for the lengthy post.

  • Issue with Oracle.sql.NUMBER in Java Stored Procedure

    When we try to make a call to the Oracle.sql.NUMBER(String) inside a java stored procedure and pass values from '01' to '09', it throws java.lang.StringIndexOutOfBoundsException: String index out of range: 3
    We use Oracle 9.2.0.6 - JServer Release 9.2.0.6.0.
    It works fine for other values. Please find below the code used for simulating the issue outside the application. Thanks.
    create or replace and compile java source named testNumber as
    import oracle.sql.NUMBER;
    import java.sql.SQLException;
    public class TestNumber
           public static String convertNumber(String parm) {
                     NUMBER nTest;
                     try {
                             nTest = new NUMBER(parm);
                             return "TRUE";
                     }catch (SQLException sqle) {
                             return "FALSE";
    create or replace function test_number (p_str in varchar2) return varchar2 as
    language Java name 'TestNumber.convertNumber(java.lang.String) return
    java.lang.String';
    select test_number('05') from dual;  - Throws exception ORA-29532: Java call terminated by uncaught Java exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
    select test_number('5') from dual; - Works fine
    select test_number('010') from dual; - Works fine

    Siva,
    I'm only guessing, but it could be an Oracle bug, in which case I suggest checking with Oracle Support.
    (You do have a support contract, don't you? ;-)
    Did you try compiling and running your java class "TestNumber" outside the database?
    Class "oracle.sql.NUMBER" should be in Oracle's JDBC driver, I believe.
    Good Luck,
    Avi.

  • Missing Defines Error in Simple Java Stored Procedure

    Anyone have any suggestions on what might be causing the unusual behavior described below? Could it be a 10g java configuration issue? I am really stuck so I'm open to just about anything. Thanks in advance.
    I am writing a java stored procedure and am getting some SQLException's when executing some basic JDBC code from within the database. I reproduced the problem by writing a very simple java stored procedure which I have included below. The code executes just fine when executed outside of the database (10g). Here is the output from that execution:
    java.class.path=C:\Program Files\jEdit42\jedit.jar
    java.class.version=48.0
    java.home=C:\j2sdk1.4.2_04\jre
    java.vendor=Sun Microsystems Inc.
    java.version=1.4.2_04
    os.arch=x86
    os.name=Windows XP
    os.version=5.1
    In getConnection
    Executing outside of the DB
    Driver Name = Oracle JDBC driver
    Driver Version = 10.1.0.2.0
    column count=1
    column name=TEST
    column type=1
    TEST
    When I execute it on the database by calling the stored procedure I get:
    java.class.path=
    java.class.version=46.0
    java.home=/space/oracle/javavm/
    java.vendor=Oracle Corporation
    java.version=1.4.1
    os.arch=sparc
    os.name=Solaris
    os.version=5.8
    In getConnection
    We are executing inside the database
    Driver Name = Oracle JDBC driver
    Driver Version = 10.1.0.2.0
    column count=1
    column name='TEST'
    column type=1
    MEssage: Missing defines
    Error Code: 17021
    SQL State: null
    java.sql.SQLException: Missing defines
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:158)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
    at oracle.jdbc.driver.OracleResultSetImpl.getString(Native Method)
    at OracleJSPTest.test(OracleJSPTest:70)
    Here is the Java code:
    // JDBC classes
    import java.sql.*;
    import java.util.*;
    //Oracle Extensions to JDBC
    import oracle.jdbc.*;
    import oracle.jdbc.driver.OracleDriver;
    public class OracleJSPTest {
    private static void printProperties(){
         System.out.println("java.class.path="+System.getProperty("java.class.path"));
         System.out.println("java.class.version="+System.getProperty("java.class.version"));
         System.out.println("java.home="+System.getProperty("java.home"));
         System.out.println("java.vendor="+System.getProperty("java.vendor"));
         System.out.println("java.version="+System.getProperty("java.version"));
         System.out.println("os.arch="+System.getProperty("os.arch"));
         System.out.println("os.name="+System.getProperty("os.name"));
         System.out.println("os.version="+System.getProperty("os.version"));
    private static Connection getConnection() throws SQLException {
         System.out.println("In getConnection");      
    Connection connection = null;
    // Get a Default Database Connection using Server Side JDBC Driver.
    // Note : This class will be loaded on the Database Server and hence use a
    // Server Side JDBC Driver to get default Connection to Database
    if(System.getProperty("oracle.jserver.version") != null){
              System.out.println("We are executing inside the database");
              //connection = DriverManager.getConnection("jdbc:default:connection:");                    
              connection = new OracleDriver().defaultConnection();
    }else{
         System.out.println("Executing outside of the DB");
         DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
         connection = DriverManager.getConnection("jdbc:oracle:thin:@XXX.XXX.XXX.XX:XXXX:XXXX","username","password");
    DatabaseMetaData dbmeta = connection.getMetaData();
    System.out.println("Driver Name = "+ dbmeta.getDriverName());
    System.out.println("Driver Version = "+ dbmeta.getDriverVersion());
    return connection;
    public static void main(String args[]){     
         test();     
    public static void test() {   
         printProperties();
    Connection connection = null; // Database connection object
    try {
         connection = getConnection();
         String sql = "select 'TEST' from dual";
         Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery(sql);     
         ResultSetMetaData meta = rs.getMetaData();     
         System.out.println("column count="+meta.getColumnCount());
         System.out.println("column name="+meta.getColumnName(1));
         System.out.println("column type="+meta.getColumnType(1));
         if(rs.next()){
              System.out.println(rs.getString(1));
    } catch (SQLException ex) { // Trap SQL Errors
         System.out.println("MEssage: " + ex.getMessage());
         System.out.println("Error Code: " + ex.getErrorCode());
         System.out.println("SQL State: " + ex.getSQLState());
         ex.printStackTrace();
    } finally {
    try{
    if (connection != null || !connection.isClosed())
    connection.close(); // Close the database connection
    } catch(SQLException ex){
    ex.printStackTrace();
    Message was edited by:
    jason_mac

    Jason,
    Works for me on Oracle 10.1.0.3 running on Red Hat Enterprise Linux AS release 3 (Taroon).
    Java code:
    import java.sql.*;
    * Oracle Java Virtual Machine (OJVM) test class.
    public class OjvmTest {
      public static void test() throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:default:connection:");
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
          ps = conn.prepareStatement("select 'TEST' from SYS.DUAL");
          rs = ps.executeQuery();
          if (rs.next()) {
            System.out.println(rs.getString(1));
        finally {
          if (rs != null) {
            try {
              rs.close();
            catch (SQLException sqlEx) {
              System.err.println("Error ignored. Failed to close result set.");
          if (ps != null) {
            try {
              ps.close();
            catch (SQLException sqlEx) {
              System.err.println("Error ignored. Failed to close statement.");
    }And my PL/SQL wrapper:
    create or replace procedure P_J_TEST as language java
    name 'OjvmTest.test()';And here is how I execute it in a SQL*Plus session:
    set serveroutput on
    exec dbms_java.set_output(2000)
    exec p_j_testGood Luck,
    Avi.

  • Calling a servlet from a Java Stored Procedure

    Hey,
    I'm trying to call a servlet from a Java Stored Procedure and I get an error.
    When I try to call the JSP-class from a main-method, everything works perfectly.
    Java Stored Procedure:
    public static void callServlet() {
    try {
    String servletURL = "http://127.0.0.1:7001/servletname";
    URL url = new URL(servletURL);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestProperty("Pragma", "no-cache");
    conn.connect();
    ObjectInputStream ois = new ObjectInputStream(conn.getInputStream());
    Integer client = (Integer)ois.readObject();
    ois.close();
    System.out.println(client);
    conn.disconnect();
    } catch (Exception e) {
    e.printStackTrace();
    Servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    Integer id = new Integer(10);
    OutputStream os = response.getOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(id);
    oos.flush();
    oos.close();
    response.setStatus(0);
    Grant:
    call dbms_java.grant_permission( 'JAVA_USER', 'SYS:java.net.SocketPermission','localhost', 'resolve');
    call dbms_java.grant_permission( 'JAVA_USER','SYS:java.net.SocketPermission', '127.0.0.1:7001', 'connect,resolve');
    Package:
    CREATE OR REPLACE PACKAGE pck_jsp AS
    PROCEDURE callServlet();
    END pck_jsp;
    CREATE OR REPLACE PACKAGE BODY pck_jsp AS
    PROCEDURE callServlet()
    AS LANGUAGE JAVA
    NAME 'JSP.callServlet()';
    END pck_jsp;
    Architecture:
    AS: BEA WebLogic 8.1.2
    DB: Oracle 9i DB 2.0.4
    Exception:
    java.io.StreamCorruptedException: InputStream does not contain a serialized object
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java)
    The Servlet and the class work together perfectly, only when I make the call from
    within the database things go wrong.
    Can anybody help me.
    Thank in advance,
    Bart Laeremans
    ... Desperately seeking knowledge ...

    Look at HttpCallout.java in the following code sample
    http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/jwcache/Readme.html
    Kuassi

Maybe you are looking for

  • Can I modify a pdf file containing a signature field prior to download?

    I have a pdf file I use as a template and in my .net application I fill in a few fields using pdfstamper, iTextsharp, etc.  I'm new to this. That all works. I also have a signature field in my document. After I modify the fields, with the person's na

  • How do MQLs materialise in SFDC?

    In theory 'MQL' (Marketing Qualified Lead) is an individual's stage in the marketing funnel. In my organisation it is one of the key stages in the funnel, because it is the trigger for further qualification and opportunity detection. One might say th

  • Synchronous AI, AO and DI

    Hello LabVIEW community - I am have some difficulty in getting my application to work properly - specifically monitoring the status of a DI line during AI and generating an AO waveform. The equipment I am using consists of: cDAQ 9172 chassis, 9401 DI

  • MM pricing - help required ?

    Hello all, i require your help for pricing procedure.   refer the below pricing - conditions 1 nad 2 are related to cost of a material while 3 and 4 are related to freight. Also suppose condition 2 and 4 are manual. now the requirement is - when you

  • Computer not recognizing itunes 7.0 download

    After receiving thank you for downloading itunes 7.0 message,for some reason my computer is not recognizing the download and I am in a loop of downloading and thankyou for downloading messages....what gives? How do i launch itunes 7.0 after it has be