Home » Developer & Programmer » JDeveloper, Java & XML » PL/SQL calling Java
PL/SQL calling Java [message #196693] Fri, 06 October 2006 09:23 Go to next message
Duane
Messages: 452
Registered: December 2002
Senior Member
For starters, I know nothing about Java so I'm a little in the dark here. I'm just trying to get this to work so any help would be appreciated.

I'm trying to call "getCredentialsString" or "Main". I'm just not sure how to do it with PL/SQL or even how to get it to work.


CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ITunesU" AS
import java.io.*;
import java.net.*;
import java.security.*;
import java.util.*;

public class ITunesU extends Object {

    
    public String getCredentialsString(String[] credentials) {

        // Create a buffer with which to generate the credentials string.
        StringBuffer buffer = new StringBuffer();

        // Verify and add each credential to the buffer.
        if (credentials != null) {
            for (int i = 0; i < credentials.length; ++i) {
                if (i > 0) buffer.append(';');
                for (int j = 0, n = credentials[i].length(); j < n; ++j) {
                    char c = credentials[i].charAt(j);
                    if (c != ';' && c != '\\' && c >= ' ' && c != 127) {
                        buffer.append(c);
                    } else {
                        return null;
                    }
                }
            }
        }

        // Return the credentials string.
        return buffer.toString();

    }
     
    public static void main(String argv[]) {
        
        ITunesU iTunesU = new ITunesU();
        
        String credentials = iTunesU.getCredentialsString(credentialsArray);

        String results = "/Browse/" + credentials;
        System.out.println(results);
        
    }

}
/

CREATE OR REPLACE PROCEDURE getCredentials (credentials in varchar2) AS LANGUAGE JAVA
NAME 'ITunesU.getCredentialsString (java.lang.String)';
/

CREATE OR REPLACE PROCEDURE itunesMain (credentials in varchar2) AS LANGUAGE JAVA
NAME 'itunes.main (java.lang.String)';
/
-- This one compiles with errors.  I'm not even sure if my syntax is correct for this.

Re: PL/SQL calling Java [message #196724 is a reply to message #196693] Fri, 06 October 2006 15:44 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
believe it or not - the actual error messages are relevant to diagnozing the problem. This could help...
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:952229840241
Re: PL/SQL calling Java [message #196727 is a reply to message #196693] Fri, 06 October 2006 15:59 Go to previous message
Duane
Messages: 452
Registered: December 2002
Senior Member
Ah permissions. I'll have to look into that.

I did find out how create a procedure to call "Main". It still doesn't work so maybe it's the permissions.

CREATE OR REPLACE PROCEDURE iTunes(s1 VARCHAR2) AS LANGUAGE JAVA
NAME 'ITunesU.main(java.lang.String[])';
/
Previous Topic: Using 9.2.0.4 jdbc driver with 9.2.0.8 db
Next Topic: Java Stored Procedures take longer to execute
Goto Forum:
  


Current Time: Sun Dec 11 08:00:28 CST 2016

Total time taken to generate the page: 0.09402 seconds