Java Stored Procedures + oralce.xdb.XMLType + initxdbj.sql

In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected]

(now include Listings)
In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected]
====================================================================
List 1:
sql> select NAME,TYPE,SEQUENCE,LINE,substr(text,1,80) TEXT from user_errors order BY 1,2,3,4
NAME TYPE SEQUENCE LINE
TEXT
proto4a/database/XMLTypeTest JAVA CLASS 1 0
ORA-29535: source requires recompilation
proto4a/database/XMLTypeTest JAVA SOURCE 1 0
proto4a/database/XMLTypeTest:11: Class oracle.xdb.XMLType not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 2 0
proto4a/database/XMLTypeTest:12: Class XMLTYPE not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 3 0
Info: 2 errors
==============================================================
List 2:
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XMLTYPE%';
OWNER OBJECT_NAME OBJECT_TYP
SYS /219cdace_AQxmlTypeInfoRespons JAVA CLASS
/a341e963_AQxmlTypeInfoRequest
XMLTYPE TYPE
XMLTYPE TYPE BODY
XMLTYPE_LIB LIBRARY
PUBLIC /219cdace_AQxmlTypeInfoRespons SYNONYM
/a341e963_AQxmlTypeInfoRequest
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XDB%';
no rows selected
====================================================================
List 3:
Installing and using oracle.xdb.XMLType class
The oracle.xdb.XMLType is available in the xdb_g.jar file in the ORACLE_
HOME/rdbms/jlib where ORACLE_HOME refers to the Oracle home directory.
Using oracle.xdb.XMLType inside JServer:
This class is pre-loaded in to the JServer and is available in the SYS schema.
It is not loaded however, if you have upgraded your database from an earlier
version. If you need to upload the class into the JServer, you would need to run the
initxdbj.sql file located in the ORACLE_HOME/rdbms/admin directory, while
connected as SYS.
Using oracle.xdb.XMLType on the client:
If you need to use the oracle.xdb.XMLType class on the client side, then ensure that
the xdb_g.jar file is listed in your CLASSPATH environment variable.
=====================================================================

Similar Messages

  • Speed test: PL/SQL vs. Java Stored Procedures

    I performed tests on these two procedures:
    ===========================================
    // Create a Statement
    Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    // Query the table
    ResultSet rset = stmt.executeQuery ("select SIFOB, SIFRA_GU from sezko");
    while (rset.next ()) {
    salary = rset.getInt(1);
    rset.updateInt (1, salary + 1);
    salary = rset.getInt(2);
    rset.updateInt (2, salary + 1);
    rset.updateRow();
    } // while
    conn.commit();
    // Close the RseultSet
    rset.close();
    // Close the Statement
    stmt.close();
    ===========================================
    procedure updateTable is
    cursor c_updateTable is select rowid, SIFOB, SIFRA_GU from sezko;
    begin
    for r_updateTable in c_updateTable loop
    update sezko set SIFOB = SIFOB + 1, SIFRA_GU = SIFRA_GU + 1 where rowid = r_updateTable.rowid;
    end loop;
    commit;
    end;
    ===========================================
    First procedure is written in Java (as Java Stored procedure) and second is PL/SQL.
    Java is about 10x slower than PL/SQL code.
    Can you explain bad performance results?
    thank you
    Matic & Ales

    Hi,
    I suppose the problem is not with the connection object,but with make connection to the database for every executeupdate or executeupdaterow called .Similarly for fetching the data from the database you
    can use the fetch size technique.Please check the 8.1.6 Java Developers guide for using this.
    Update Batching(For Batch updates and commits)
    Fetch Size(For Batch fetching)
    Oracle Row Pre-Fetching
    Regards
    Anand
    null

  • Issue with sending mail through java stored procedure in Oracle

    Hello
    I am using Oracle 9i DB. I created a java stored procedure to send mail using the code given below. The java class works fine standalone. When its run from Java, mail is sent as desired. But when the java stored procedure is called from pl/sql "Must issue a STARTTLS command first" error is thrown. Please let me know if am missing something. Tried the same code in 11.2.0.2 DB and got the same error
    Error:
    javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. va6sm31201010igc.6
    Code for creating java stored procedure: (T1 is the table created for debugging)
    ==================================================
    create or replace and compile java source named "MailUtil1" AS
    import java.util.Enumeration;
    import java.util.Properties;
    import javax.mail.Message;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class MailUtil1 {
    public static void sendMailwithSTARTTLS(String host, //smtp.projectp.com
    String from, //sender mail id
    String fromPwd,//sender mail pwd
    String port,//587
    String to,//recepient email ids
    String cc,
    String subject,
    String messageBody) {
    try{
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "True"); // added this line
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", from);
    props.put("mail.smtp.password", fromPwd);
    props.put("mail.smtp.port", port);
    props.put("mail.smtp.auth", "true");
    #sql { insert into t1 (c1) values ('1'||:host)};
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    #sql { insert into t1 (c1) values ('2')};
    InternetAddress[] toAddress = new InternetAddress[1];
    // To get the array of addresses
    for( int i=0; i < toAddress.length; i++ ) { // changed from a while loop
    toAddress[i] = new InternetAddress(to);
    //System.out.println(Message.RecipientType.TO);
    for( int i=0; i < toAddress.length; i++) { // changed from a while loop
    message.addRecipient(Message.RecipientType.TO, toAddress);
    if (cc!=null) {
    InternetAddress [] ccAddress = new InternetAddress[1];
    for(int j=0;j<ccAddress.length;j++){
    ccAddress[j] = new InternetAddress(cc);
    for (int j=0;j<ccAddress.length;j++){
    message.addRecipient(Message.RecipientType.CC, ccAddress[j]);
    message.setSubject(subject);
    message.setText(messageBody);
    message.saveChanges();
    #sql { insert into t1 (c1) values ('3')};
    Enumeration en = message.getAllHeaderLines();
    String token;
    while(en.hasMoreElements()){
    token ="E:"+en.nextElement().toString();
    #sql { insert into t1 (c1) values (:token)};
    token ="ConTyp:"+message.getContentType();
    #sql { insert into t1 (c1) values (:token)};
    token = "Encod:"+message.getEncoding();
    #sql { insert into t1 (c1) values (:token)};
    token = "Con:"+message.getContent();
    #sql { insert into t1 (c1) values (:token)};
    Transport transport = session.getTransport("smtp");
    #sql { insert into t1 (c1) values ('3.1')};
    transport.connect(host, from, fromPwd);
    #sql { insert into t1 (c1) values ('3.2')};
    transport.sendMessage(message, message.getAllRecipients());
    #sql { insert into t1 (c1) values ('3.3')};
    transport.close();
    #sql { insert into t1 (c1) values ('4')};
    catch(Exception e){
    e.printStackTrace();
    String ex= e.toString();
    try{
    #sql { insert into t1 (c1) values (:ex)};
    catch(Exception e1)
    Edited by: user12050615 on Jan 16, 2012 12:18 AM

    Hello,
    Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
    So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
    Thanks
    Srikanth
    Edited by: user12050615 on Jan 16, 2012 12:17 AM

  • Oracle stored procedure to Java stored procedure

    Hello,
    I got a school assignement "Create a java stored procedure and call it out from JAVA program outside database".
    I've done it, but in case of JAVA stored procedure I have the procedure written in PL/SQL.
    PL/SQL procedure:
    CREATE OR REPLACE PROCEDURE getDogInfo
    (Dog_ID IN NUMBER, Dog_name OUT VARCHAR) AS
    BEGIN
      SELECT Name INTO Dog_name
      FROM Dog_family
      WHERE ID = Dog_ID;
    END;
    How do I convert it to JAVA stored procedure?
    Maybe it's just plain stupid and I should keep it as PL/SQL? I don't know if I have done it right.
    Also I don't know what to do with IN/OUT parameters in JAVA.

    Could my procedure java class look something like this? I am aware that I have to make a PL/SQL function that is associated with JAVA method CALL, just asking about JAVA Class at the moment.
    import java.sql.*;
    import java.io.*;
    public class Procedure {
      public static void getDogInfo (int Dog_ID, String Dog_name)
        throws SQLException
        { String sql =
          "SELECT Dog_name INTO Name FROM Dog_family WHERE ID = Dog_ID";
        try { Connection conn = DriverManager.getConnection("jdbc:default:connection:");
          PreparedStatement apstmt = conn.prepareStatement(sql);
          apstmt.setInt(1, Dog_ID);
          apstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
          ResultSet rset = apstmt.executeQuery();
          rset.close();
          apstmt.close(); //Connection close
        catch (SQLException e) {System.err.println(e.getMessage());
    My java program looks like this:
    package client;
    import java.sql.*;
    public class JDBCPiemers {
        static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver";
        static final String DB_URL = "jdbc:oracle:thin:@localhost:1521:ORCL";
        static final String USER = "SYSTEM";
        static final String PASS = "asdasd";
        private String sql;
        public static void main(String[] args) throws ClassNotFoundException, SQLException {
            Connection conn = null;
            CallableStatement stmt = null;
            try {
                //Registering JDBC driver
                Class.forName("oracle.jdbc.driver.OracleDriver");
                System.out.println("Connecting to database ...");
                conn = DriverManager.getConnection(DB_URL, USER, PASS);
                System.out.println("Preparing command...");
                String SQL = "{CALL getDogInfo (?, ?)}";
                stmt = conn.prepareCall(SQL);
                int Dog_ID = 4;
                stmt.setInt(1,Dog_ID);
                stmt.registerOutParameter(2, java.sql.Types.VARCHAR);
                System.out.println("CALL of JAVA stored procedure ...");
                // Executing SQL
                stmt.execute();
                //Using getXXX method
                String Name = stmt.getString(2);
                System.out.println("Printing results ...");
                System.out.println("ID NR. " +Dog_ID + " is Dog with
    a name  '" + Name + "'" );      
                stmt.close();
                conn.close(); }
                catch(SQLException se) {
                    //JDBC Errors
                    se.printStackTrace(); }
                catch(Exception e) {
                    //Errors Class.forName
                    e.printStackTrace(); }
                finally {
                    //Clossing resurses
                    try {if(stmt!=null)
                    stmt.close(); }
                catch(SQLException se2) {}
                    try {if(conn!=null)
                    conn.close(); }
                    catch(SQLException se) {se.printStackTrace(); }
                    //finally block end
                } // try
                System.out.println("Closing program."); }}

  • Using XMLType in a Java Stored Procedure

    I have the following piece of java test code that attempts to read an XMLType object from the database. When I run this client side, using either the oci or thin driver it works fine. When I run the same code as a java stored procedure I get the exception shown below.
    (The problem was first seen on 9.2.0.3/Win2K. Ive patched to 9.2.0.4 and am still getting the same error)
    Can anybody please help?
    Thanks
    Java Test Code:
    ===============
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.xdb.*;
    public class Test {
    public static void main(String[] args) throws Exception {
    System.out.println(run());
    public static String run() throws Exception {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // client side THICK
    //Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=ORACLE)))", "scott", "tiger");
    // client side THIN
    //Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORACLE", "scott", "tiger");
    // server side
    Connection conn = DriverManager.getConnection("jdbc:default:connection");
    OracleCallableStatement stmt = (OracleCallableStatement)conn.prepareCall("{? = call XDBUriType('/test.xml').getXML()}");
    stmt.registerOutParameter (1, OracleTypes.OPAQUE,"SYS.XMLTYPE");
    stmt.execute();
    XMLType xml = XMLType.createXML(stmt.getOPAQUE(1));
    return xml.getStringVal();
    SQLPLUS TRACE:
    ==============
    SQL> VARIABLE res VARCHAR2(4000);
    SQL> call run() into :res;
    call run() into :res
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.Exception: Unimplemented Feature
    Dump File:
    ==========
    Dump file c:\oracle9i\admin\oracle\udump\oracle_ora_4964.trc
    Fri Oct 24 12:04:30 2003
    ORACLE V9.2.0.3.0 - Production vsnsta=0
    vsnsql=12 vsnxtr=3
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Personal Oracle9i Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Instance name: oracle
    Redo thread mounted by this instance: 1
    Oracle process number: 12
    Windows thread id: 4964, image: ORACLE.EXE
    *** 2003-10-24 12:04:30.000
    *** SESSION ID:(10.121) 2003-10-24 12:04:30.000
    java.lang.Exception: Unimplemented Feature
    at oracle.xdb.spi.XDBContext.getServerEnv(XDBContext.java)
    at oracle.xdb.XMLType.initConn(XMLType.java:1874)
    at oracle.xdb.XMLType.<init>(XMLType.java:846)
    at oracle.xdb.XMLType.createXML(XMLType.java:469)
    at cms.Test.run(Test.java:27)

    I have the very same problem. Somebody from Oracle Corp please reply. If this is a bug, please do not let us waste time to research a solution. Otherwise, point a way out!
    Thanks,

  • Accessing XMLType in a Java Stored Procedure

    I have the following piece of java test code that attempts to read an XMLType object from the database. When I run this client side, using either the oci or thin driver it works fine. When I run the same code as a java stored procedure I get the exception shown below.
    (My system is 9.2.0.3 on Win2k)
    Can anybody help?
    Thanks
    Java Test Code:
    ===============
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.xdb.*;
    public class Test {
    public static void main(String[] args) throws Exception {
    System.out.println(run());
    public static String run() throws Exception {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // client side THICK
    //Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=ORACLE)))", "scott", "tiger");
    // client side THIN
    //Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORACLE", "scott", "tiger");
    // server side
    Connection conn = DriverManager.getConnection("jdbc:default:connection");
    OracleCallableStatement stmt = (OracleCallableStatement)conn.prepareCall("{? = call XDBUriType('/test.xml').getXML()}");
    stmt.registerOutParameter (1, OracleTypes.OPAQUE,"SYS.XMLTYPE");
    stmt.execute();
    XMLType xml = XMLType.createXML(stmt.getOPAQUE(1));
    return xml.getStringVal();
    SQLPLUS TRACE:
    ==============
    SQL> VARIABLE res VARCHAR2(4000);
    SQL> call run() into :res;
    call run() into :res
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.Exception: Unimplemented Feature
    Dump File:
    ==========
    Dump file c:\oracle9i\admin\oracle\udump\oracle_ora_4964.trc
    Fri Oct 24 12:04:30 2003
    ORACLE V9.2.0.3.0 - Production vsnsta=0
    vsnsql=12 vsnxtr=3
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Personal Oracle9i Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    Windows 2000 Version 5.0 Service Pack 4, CPU type 586
    Instance name: oracle
    Redo thread mounted by this instance: 1
    Oracle process number: 12
    Windows thread id: 4964, image: ORACLE.EXE
    *** 2003-10-24 12:04:30.000
    *** SESSION ID:(10.121) 2003-10-24 12:04:30.000
    java.lang.Exception: Unimplemented Feature
    at oracle.xdb.spi.XDBContext.getServerEnv(XDBContext.java)
    at oracle.xdb.XMLType.initConn(XMLType.java:1874)
    at oracle.xdb.XMLType.<init>(XMLType.java:846)
    at oracle.xdb.XMLType.createXML(XMLType.java:469)
    at cms.Test.run(Test.java:27)

    I have the very same problem. Somebody from Oracle Corp please reply. If this is a bug, please do not let us waste time to research a solution. Otherwise, point a way out!
    Thanks,

  • Calling the Java Method in PL/SQL Java Stored procedure errors out

    Hi,
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........
    I have written a java class by name XYZ which has a method ABC for which there are 9 arguements being passed and its a VOID method.
    This java class has been loaded into ORACLE using DBMS_JAVA.LOADJAVA pkg, Now this class is being called in the oracle as a JAVA Stored procedure...... When ever im trying to call the procedure it throws the following error
    ORA-29531: no method
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    The code snippet as follows
    JAVA CODE:
    Class xyz
    public static void Abc (String hostName,
    int port,
    String serviceURL,
    String soapAction,
    int timeOut,
    String wsUser,
    String wsPasWd,
    String keyStore,
    String keyStorePasWd)
    //method implementation
    JAVA STORED PROCEDURE:
    create OR REPLACE procedure ABC_JAVA_SP_CALL
    (p_hostname in varchar2, p_port in number, p_serviceurl in varchar2, p_soapaction in varchar2, p_timeout in number, p_wsuser in varchar2, p_wspasswd in varchar2, p_ks_path in varchar2, p_ks_passwd in varchar2)
    as
    language java
    name 'xyz.Abc(java.lang.String, int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)';
    When i try to call
    declare
    p_hostname varchar2(100);
    p_port number;
    p_serviceurl varchar2(100);
    p_soapaction varchar2(100);
    p_timeout number;
    p_wsuser varchar2(100);
    p_wspasswd varchar2(100);
    p_ks_path varchar2(100);
    p_ks_passwd varchar2(100);
    begin
    //SP which returns the values for the required parameters.
    comppkg.getvcsinfo(
    p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd
    Layer7_icengc_ws_tes(p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd);
    end;
    This thing ends up with
    29531. 00000 - "no method %s in class %s"
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    Im not understanding what wrong am i doing
    pls help
    Edited by: madhusudan on Feb 12, 2013 8:07 PM

    Hello,
    there is the forum {forum:id=65} for questions about using Java within Oracle.
    Regards
    Marcus
    Edited by: Marwim on 13.02.2013 07:56
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........You got the hint to the correct forum alread in another thread {message:id=10837976}
    And if you think this is not related to Java but PL/SQL, then you should ask in {forum:id=75}

  • Java stored procedure vs. PL-SQL vs. external java program

    Hi,
    I'm using a stored procedure for running a query and a few consequent updates. Currently I'm using Java stored procedure for that, which was my choice for simplicity on one hand, and running with the DB on the other.
    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.
    Any experiences? recommendations?
    Thanks,
    Dawg

    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.This isn't strange at all. See: Oracle's JVM (Aurora) is an independent Java Virtual Machine implementation, in accordance to specification. It implements all necessary parts of it (I think so). When you use an external JVM (I assume it's Sun's HotSpot JVM) you use completely different product. It is implemented in different way, it has many different code parts.
    One of the biggest differences between Oracle's JVM and Sun's JVM is [Just-in-Time compiler|http://en.wikipedia.org/wiki/Just-in-time_compilation]. Oracle has implemented it only in the 11g version of database, i.e. 2 years ago, while Sun performed it back in 2000 and continues to improve it for the last 9 years. That would explain obvious differences between Java program inside and outside the DB: they are executed in absolutely different worlds. Diffs could be up to 10x times or more - that's not unusual.
    If you are on 10g and want to compare performance of stored Java procedure vs external program, then you might use additional command-line instruction for external program to disable JIT:
    -XintPS. I wouldn't use Java for your task - that's a total overkill. Use simple SP instead.

  • 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.

  • SQL Server connection in Java Stored Procedures

    Is it possible to establish a connection to microsoft sql server through java stored procedures. When I try to create a connetion to SQL Server I am getting the following exception in trace file
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
    at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
    at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
    at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    The connection details are correct and I am able to connect when I run the java code externally. Thanks in advance for the help

    Can you connect to the MSSQL database from inside Oracle in (say) a SQL*Plus or SQL Developer session?
    In other words, is the problem in the Java or the database linkages? Are you using Heterogeneous Services or Transparent Gateways?
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Java Stored Procedure functions in SQL DML - multiple invocations

    When running a java stored procedure as part of a DML statement the procedure is invoked 10-15 times for each row that is updated.
    For example:
    Update mytable set mycolumn = myjsp(somecolumn);
    I undertand that this was a known bug with the JDBC driver. Has it been fixed? Is there a workaround?
    We are using 8.1.6 on NT 4
    Thanks
    Julian

    Hello ,
    I tried here, and it seems to call the function once for each row
    eg :
    package package90;
    public class Class1 extends Object {
    public int get_data(int i)
    return i+10;
    Published the get_data function as
    myproject67.get_data
    SQL> connect scott/tiger@orcl8i
    Connected.
    SQL> set serveroutput on
    SQL> exec dbms_java.set_output(5000);
    PL/SQL procedure successfully completed.
    SQL> select * from test_java;
    NO1
    10
    10
    SQL> insert into test_java values (20);
    1 row created.
    SQL> select * from test_java;
    NO1
    10
    10
    20
    SQL> update test_java set no1=myproject67.get_data(no1);
    Called
    Called
    Called
    3 rows updated.
    SQL> select * from test_java;
    NO1
    20
    20
    30
    SQL>

  • Connecting to SQL Server and MYSQL from a Java stored procedure

    hope someone can help with this. i'm trying to connect to different databases (My SQL, SQL Server) from a java stored procedure. when invoking from within an oracle 9i database, i get the java exception error -
    "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?java.security.AccessControlException)".
    this store procedure works fine when invoked from outside of oracle. any replies would be greatly appreciated. thanks!

    the correct drivers have been loaded. it works when called from outside of oracle. only when invoking from within oracle do we get the error message "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?(java.security.AccessControlException)". it sounds like a permissions/security/configuration issue - oracle is not allowing access to the machine/port for the MySQL or SQL Server database. appreciate the responses so far.

  • Error while executing java stored procedure from a pl/sql procedure

    We have a requirement where we need to execute JAVA code stored in an Oracle database (Java Stored Procedure). This code uses some JAR files which we have already loaded without any errors in the database.
    The class file was also loaded in the database without any errors. But when we execute the method of this class (JAVA code), it gives the following error:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NoClassDefFoundError
    Is there any way of debugging the code and getting to know where exactly the problem is? Or, any tool/software available for doing the same.
    Any pointers would be of great help!
    Thanks in advance

    Hi Uday,
    My guess is that there is a problem with your java stored procedure that is causing the "ExceptionInInitializer" error to be thrown. According to the javadoc:
    is thrown to indicate that an exception occurred during
    evaluation of a static initializer or
    the initializer for a static variable
    Since I didn't see any of your code in your post, I can't help you much more, I'm afraid. Perhaps if you would provide some more details, I may be able to help you some more. I think the following details would be helpful:
    1. Complete error message and stack trace you are getting.
    2. The section of your java code that you think is causing the problem.
    3. Oracle database version you are using.
    Good Luck,
    Avi.

  • Calling Java Stored Procedure failed SQLXML

    I tried to upload a simple class to Oracle in which I want to use java.sql.SQLXML class using:
    loadjava -u user/passwd@host:1521:xyz -v -resolve C:\develop\workspaces\Test\src\lbb\apc\test\JavaStoredProcedureTest.java
    loadjava answers with:
    creating : source lbb/apc/test/JavaStoredProcedureTest
    loading  : source lbb/apc/test/JavaStoredProcedureTest
    resolving: source lbb/apc/test/JavaStoredProcedureTest
    errors   : source lbb/apc/test/JavaStoredProcedureTest
        ORA-29535: Quelle erfordert Neukompilierung
        lbb/apc/test/JavaStoredProcedureTest:6: cannot find symbol
        symbol  : class SQLXML
        location: package java.sql
        import java.sql.SQLXML;Then I found that the Oracle JDBC driver does not support the SQLXML type, thus changing my program to use XMLType:
    XMLType sqlXml = (XMLType)rs.getSQLXML(1);but it doesn't help as well as it doesn't help to use
    Clob clob = rs.getClob(1);Finally I tried (and failed) to use
    Object obj = rs.getObject(1);
    results in:
    java.sql.SQLException: ORA-29532:Java call terminated by uncaught Java exception:What can I do to solve this problem?

    I wrote it for an example. sorry i should be clear.
    Here is the code i am running check WORKING & NOT WORKING lines. What am i missing
    PL SQL package
    CREATE OR REPLACE PACKAGE BODY APPS.hypr_Reference_designator as
    function hypr_xsl ( dbInstance IN VARCHAR2, Parent_ItemNum IN VARCHAR2)
    return varchar2
    as language java name 'hypr_ref_designator_xsl.hypr_xsl(java.lang.String,java.lang.String) return java.lang.String';
    procedure hypr_xsl(dbInstance IN VARCHAR2, Parent_ItemNum IN VARCHAR2)
       is
       itemNum VARCHAR2(30);
       db Varchar2(30);
       print_string varchar2(200);
       begin
          db:=dbInstance;
            itemNum:=Parent_ItemNum;
          print_string := hypr_xsl(db,itemNum);  --NOT WORKING
                print_string := hypr_xsl('DEV','123'); --WORKING
          commit;
          DBMS_OUTPUT.PUT_LINE(print_string || db || itemNum);
       end hypr_xsl;
    END hypr_Reference_designator;Java Stored Procedure
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED APPS.HYPR_REF_DESIGNATOR_XSL as import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import jxl.*;
    import oracle.jdbc.driver.*;
    import java.sql.*;
    import java.util.Properties;
    public class hypr_ref_designator_xsl {
        public hypr_ref_designator_xsl() {
        public static void main(String[] args) {
    public static String hypr_xsl(String  dbinstance, String parent_itemNum) {
    System.out.print(dbinstance);
    System.out.print(parent_itemNum);
    return "";
    //does some process here
    }

  • Error while deploying a Java Stored Procedure using JDeveloper

    Hi,
    I was going thru the Oracle By Example article: "Developing SQL and PL/SQL with JDeveloper". (http://www.oracle.com/technology/obe/obe9051jdev/ide1012/plsqlobe/obeplsql.htm)
    One of the items in this article is - "Creating and Deploying a Java Stored Procedure"
    I was able to create a java class, compile it. Created a deployment profile. created a pl/sql wrapper. While trying to deploy the java stored procedure, I am getting the following error:
    Invoking loadjava on connection 'hr_conn' with arguments:
    -order -resolve -thin
    errors : class package1/mypackage/JavaStoredProc
    ORA-29521: referenced name java/lang/StringBuilder could not be found
    The following operations failed
    class package1/mypackage/JavaStoredProc: resolution
    oracle.aurora.server.tools.loadjava.ToolsException: Failures occurred during processing
         at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:863)
         at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:116)
         at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:46)
         at oracle.jdevimpl.deploy.OracleDeployer.deploy(OracleDeployer.java:97)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:474)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:361)
         at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:285)
         at oracle.jdevimpl.deploy.StoredProcProfileDt$Action$1.run(StoredProcProfileDt.java:383)
    #### Deployment incomplete. #### Oct 27, 2005 1:38:56 PM
    Appreciate your help on this..

    I am using Jdeveloper 10.1.3 Early Access Version. JDK comes with it. I also have another JDK on my machine (JDK1.4.2_09)

Maybe you are looking for

  • Satellite U400-10J - power is on but NO LCD dsiplay

    Good day. I have a new Toshiba Satellite U400-10J. I did not turn it off after i use it and then when i get back it was hanged up so i decided to turn it off by pressing the power button in few seconds. The next day when i decided to use my laptop ag

  • Adobe Reader V 9.3.3 Update Available Today

    Since the fix for Adobe Reader and Adobe Acrobat are now available, what version is required to be installed to use this update? It would be so helpful to have a fix that could be installed over 9.3.0. Recent updates and fixes have required multiple

  • Online Courses Problems

    Hi, The links about Oracle9i Database Online Courses Training at OTN seems to be broken, any ideas? Thanks in advance. The URL with courses is the following: http://www.oracle.com/technology/idevelop/online/courses/oln/getting_started.html sve

  • Integrating mod_plsql reports with Oracle apps. Maddening dilemma.

    I'm hoping there is some guru out there that has the perfect solution to this maddening dilemma I'm facing. The crux of the issue is this. I've created mod_plsql reports that can accept a session_id with which they can set a user context based on glo

  • How to delete an iCould account?

    I tried to delete my MobileMe account and then when I went to sign back in with my Apple ID for iCloud in settings, my MobileMe account came back.