oracle调用JAVA存储过程出错
在网上找到资料,模仿人家的步骤,先定义了一个Main.java文件,将程序参数写入一个已有文件中
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String args) {
// TODO code application logic here
String datas = "/home/oracle/test.txt";
File data = new File(datas);
try {
StringBuffer content = new StringBuffer();
content.append("Hello");
content.append(args);
FileWriter writer = new FileWriter(data,true);
writer.write(content.toString());
writer.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
然后使用loadjva -user user/pass@test -o -v -f -r /home/oracle/Main.java
提示导入JAVA程序成功
然后在sqlplus里创建一个存储过程
create or replace procedur file_test(name varchar2) as language java name 'Main.main(java.lang.String)';
/
这个时候出现 Warning:procedure created with compilation errors.
执行 show errors procedure file_test;
得到
0/0 PL/SQL:Compilation unit analysis terminated
1/55 PLS-00311:the declaration of "Main.main(java.lang.String)" is incomplete or malformed
不知道原因在什么地方啊