dbTalk Databases Forums  

Java store procedure that reference a external library.

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Java store procedure that reference a external library. in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
aem
 
Posts: n/a

Default Java store procedure that reference a external library. - 04-02-2008 , 10:38 AM






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/tcmpass (AT) sgfdes (DOT) 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

Reply With Quote
  #2  
Old   
Luca_DBA
 
Posts: n/a

Default Re: Java store procedure that reference a external library. - 04-03-2008 , 12:23 AM






On Apr 2, 11:38 am, aem <a.e.menen... (AT) gmail (DOT) com> wrote:
Quote:
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 (DOT) 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/B...6/security.htm
# 1002127

Sorry for my poor English.
I hope I have helped you,
Good luck,
Luca.


Reply With Quote
  #3  
Old   
Luca_DBA
 
Posts: n/a

Default Re: Java store procedure that reference a external library. - 04-03-2008 , 12:23 AM



On Apr 2, 11:38 am, aem <a.e.menen... (AT) gmail (DOT) com> wrote:
Quote:
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 (DOT) 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/B...6/security.htm
# 1002127

Sorry for my poor English.
I hope I have helped you,
Good luck,
Luca.


Reply With Quote
  #4  
Old   
Luca_DBA
 
Posts: n/a

Default Re: Java store procedure that reference a external library. - 04-03-2008 , 12:23 AM



On Apr 2, 11:38 am, aem <a.e.menen... (AT) gmail (DOT) com> wrote:
Quote:
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 (DOT) 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/B...6/security.htm
# 1002127

Sorry for my poor English.
I hope I have helped you,
Good luck,
Luca.


Reply With Quote
  #5  
Old   
Luca_DBA
 
Posts: n/a

Default Re: Java store procedure that reference a external library. - 04-03-2008 , 12:23 AM



On Apr 2, 11:38 am, aem <a.e.menen... (AT) gmail (DOT) com> wrote:
Quote:
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 (DOT) 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/B...6/security.htm
# 1002127

Sorry for my poor English.
I hope I have helped you,
Good luck,
Luca.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.