This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Calling a java object fromn a store procedure no idea how to get it to work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Calling a java object fromn a store procedure no idea how to get it to work" Watch "Calling a java object fromn a store procedure no idea how to get it to work" New topic
Author

Calling a java object fromn a store procedure no idea how to get it to work

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
I have this piece of code, which works as a standalone program: It takes in the en_var and returns a path.

But it wont work when called from a store procedure
p = rt.exec("echo "+envar); returns null.
os = System.getProperty("os.name"); returns Solaris
name = System.getProperty("user.name"); returns null
home = System.getProperty("user.home"); returns null
dir = System.getProperty("user.dir"); returns null



import java.util.*;

class translate
{
public static String translatePath(String envar)
{
Runtime rt = Runtime.getRuntime();
int bufSize = 4096;
byte buffer[] = new byte[bufSize];
String path = null;
Process p = null;
String os = null;
String name = null;
String home = null;
String dir = null;
SecurityManager sm = null;

int len = 0;

try
{
System.out.println("Calling echo "+envar);
os = System.getProperty("os.name");
name = System.getProperty("user.name");
home = System.getProperty("user.home");
dir = System.getProperty("user.dir");
sm = System.getSecurityManager();
p = rt.exec("echo "+envar);


BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
while ((len = bis.read(buffer, 0, bufSize)) != -1)
{
System.out.write(buffer, 0, len);
}
path = new String(buffer);
//p.waitFor();
bis.close();
return path;
}
catch(Exception e)
{
System.out.println("Exception "+e);
return "ProcessProblem";
}

//path = "/rims/live/log";

}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling a java object fromn a store procedure no idea how to get it to work