PL/SQL calling Java [message #196693] |
Fri, 06 October 2006 09:23 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Duane
Messages: 559 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 #196727 is a reply to message #196693] |
Fri, 06 October 2006 15:59 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Duane
Messages: 559 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[])';
/
|
|
|