Re: Java store procedure that reference a external library.

From: Luca_DBA <lucaneto_at_gmail.com>
Date: Wed, 2 Apr 2008 22:23:28 -0700 (PDT)
Message-ID: <e25b87f7-88a9-4b2d-b76a-c310d9b77f7c@l42g2000hsc.googlegroups.com>


On Apr 2, 11:38 am, aem <a.e.menen..._at_gmail.com> wrote:
> Hi. I have this problem.
> I can to compile a java store procedure that reference a external
> library.
> I tested this source in eclipse and execute correctly.
> I want to copy a file using SFTP from external server to Oracle
> server.
> I have loaded the external library "jsch-0.1.37.jar" using javaload,
> and compiled the java store procedure. But I have problem with the
> load and with the java source.
> The java source not find the external library.
>
> I use:
>
> Oracle 9.0.2.8.0
>
> loadjava -definer -grant plsql -oci8 -resolve -schema tcm -synonym -
> user tcm/tcmp..._at_sgfdes.sion -verbose C:\aem\work\jsch-0.1.37.jar
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> create or replace and compile java source named copia_sftp as
> import com.jcraft.jsch.*;
>
> /**
> * class Copia_Sftp
> */
> public class Copia_Sftp extends Object
> {
>
> public static String ejecutar(String host,
> String user,
> String passwd,
> int port,
> String remote_path,
> String local_path,
> String file_name) {
>
> String error = "0";
> String message = "";
>
> try {
> JSch jsch = new JSch();
>
> Session session = jsch.getSession(user, host, port);
>
> // Crea una session .
> UsuarioSFTP ui = new UsuarioSFTP();
> ui.setClave(passwd);
> session.setUserInfo(ui);
> session.connect();
>
> // Abre el canal.
> Channel channel = session.openChannel("sftp");
> channel.connect();
> ChannelSftp c = (ChannelSftp) channel;
>
> try {
> try {
> c.get(remote_path + file_name, local_path + file_name);
> return ((new String (error + message)));
> } catch (SftpException e) {
> e.printStackTrace();
> error = "1";
> message = e.toString();
> System.out.println(e.toString());
> }
>
> session.disconnect();
> } catch (Exception e) {
> e.printStackTrace();
> error = "1";
> message = e.toString();
> System.out.println(e);
> }
> } catch (Throwable e) {
> error = "1";
> message = e.toString();
> e.printStackTrace();
> } finally {
> return ((new String (error + message)));
> }
> }
>
> }
>
> /**
> * class UsuarioSFTP
> */
> public class UsuarioSFTP implements UserInfo,UIKeyboardInteractive
> {
>
> private String clave;
> private String nombre;
>
> public String getPassphrase() {
> return null;
> }
>
> public String getPassword() {
> return clave;
> }
>
> public boolean promptPassword(String message) {
> return true;
> }
>
> public boolean promptPassphrase(String message) {
> return true;
> }
>
> public boolean promptYesNo(String message) {
> return true;
> }
>
> public void showMessage(String message) {
>
> }
>
> public void setClave(String clave) {
> this.clave = clave;
> }
>
> public String getNombre() {
> return nombre;
> }
>
> public void setNombre(String nombre) {
> this.nombre = nombre;
> }
>
> public String[] promptKeyboardInteractive(String destination,
> String name,
> String instruction,
> String[] prompt,
> boolean[] echo) {
>
> String [] resultado = new String [prompt.length];
> resultado [0] = clave;
> return resultado;
> }
>
> }
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> When I compile the java store procedure.
>
> Compilation errors for JAVA SOURCE COPIA_SFTP
>
> Error: Interface UIKeyboardInteractive of class UsuarioSFTP not
> found.
> Line: 69
> Text: public class UsuarioSFTP implements
> UserInfo,UIKeyboardInteractive
>
> Error: Interface UserInfo of class UsuarioSFTP not found.
> Line: 69
> Text: public class UsuarioSFTP implements
> UserInfo,UIKeyboardInteractive
>
> Error: Class JSch not found.
> Line: 23
> Text: JSch jsch = new JSch();
>
> Thank a lot.
> Alvaro

Hello Alvaro, how are you?
I had this same problem once, and were problems with permissions. Review the permissions using the views USER_JAVA_POLICY and DBA_JAVA_POLICY. http://download.oracle.com/docs/cd/B10501_01/java.920/a96656/security.htm # 1002127

Sorry for my poor English.
I hope I have helped you,
Good luck,
Luca. Received on Thu Apr 03 2008 - 00:23:28 CDT

Original text of this message