Call java from PL/SQL
1. Create file java
public class Hello{
public static String world()
{
return "Hello world";
}
}
2. Complier file java
Javac Hello.java
3. Loadjava to database
C:\app\shbadmin\product\11.2.0\client_1\BIN>loadjava -r -user xxx@xxx d:
\Hello.class
4.Create function database
CREATE OR REPLACE FUNCTION helloworld RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Hello.world () return java.lang.String';
5 . Result:
select helloworld() from dual;
Note: Version javac and loadjava the same if different error : \
java.lang.UnsupportedClassVersionError
Không có nhận xét nào:
Đăng nhận xét