oracle调用java方法的例子
在oracle中调用java程序,注意:java方法必须是static类型的,如果想在JAVA中使用system.out/err输出log.
需要在oracle 中执行"call dbms_java.set_output(5000);".
一、helloWord
1 编写JAVA程序,也是在SQL/PLUS中写,并执行.
create or replace and compile java source named hello as
public class Hello {
static public String Message(String name) {
return " Hello, " + name;
}
}
/
2 发布JAVA程序
create or replace function hello (name VARCHAR2 ) return VARCHAR2
as language java name
' Hello.Message (java.lang.String) return java.lang.String ' ;
/
3 使用发面的JAVA程序
select hello( ' world! ' ) from dual;
HELLO( ' world! ' )
-- -------------
Hello world!
二、在JAVA程序中使用SQL
1 编写JAVA程序
create or replace and compile java source named test as
import java.sql. * ;
import java. text .DateFormat;
import java. text .SimpleDateFormat;
import java.util. * ;
import java.util.Date;
import com.ccit.wcsmp.comm.vo.daovo.MBTResultVO;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
public class Test
{
static public String message(String name) {
String sql = " select sysdate as dd from dual";
String tmpStr = null ;
PreparedStatement pstmt = null ;
ResultSet rs = null ;
Connection conn = null ;
try
 
相关文档:
TBCPMessageFactory.java
/**
* 文件名: TBCPMessageFactory.java
*/
package tbcpstack;
import java.text.MessageFormat;
import org.apache.log4j.Logger;
import TBCPException;
/**
*
* TODO TBCP消息构建工厂
*/
public class TBCPMessageFactory {
/**
* Logger for this class
......
1995年5月23日,Java语言诞生
1996年1月,第一个JDK-JDK1.0诞生
1996年4月,10个最主要的操作系统供应商申明将在其产品中嵌入JAVA技术
1996年9月,约8.3万个网页应用了JAVA技术来制作
1997年2月18日,JDK1.1发布
1997年4月2日,JavaOne会议召开,参与者逾一万人,创当时全球同类会议规模之纪录
1997年9 ......
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import sun.net.TelnetOutputStream;
import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;
public class download ...{
& ......
以下代码能否编译通过,如果不能,请说明理由,如果能,请说明结果。
public class a {
{
System.out.println("AAA");
}
a() {
System.out.println("BBB");
}
{
System.out.println("CCC");
}
class aa extends a {
{
new a();
System.out.prin ......