Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java µ÷Óà Oracle ´æ´¢¹ý³Ì·µ»Ø½á¹û¼¯

Oracle ´æ´¢¹ý³Ì·µ»Ø½á¹û¼¯Óà ref cursor ʵÏÖ¡£
ÊÔÑé²½ÖèÈçÏ£º
1. ½¨Á¢ ref cursor ÀàÐͺ͹ý³Ì
CREATE OR REPLACE PACKAGE types
AS
    TYPE ref_cursor IS REF CURSOR;
END;
/
CREATE TABLE STOCK_PRICES(
    RIC VARCHAR(6) PRIMARY KEY,
    PRICE NUMBER(7,2),
    UPDATED DATE );
/
CREATE OR REPLACE FUNCTION sp_get_stocks(v_price IN NUMBER)
    RETURN types.ref_cursor
AS
    stock_cursor types.ref_cursor;
BEGIN
    OPEN stock_cursor FOR
    SELECT ric,price,updated from stock_prices WHERE price < v_price;
    RETURN stock_cursor;
END;
2. Óà sqlplus ²âÊÔ¹ý³Ì
SQL> var results refcursor
SQL> exec :results := sp_get_stocks(20.0)
SQL> print results
3. ´Ó Java µ÷ÓÃ
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
public class JDBCDemo {
    /**
    * Compile-time flag for deciding which query to use
    */
    private boolean useOracleQuery = true;
    /**
    * Class name of Oracle JDBC driver
    */
    private String driver = "oracle.jdbc.driver.OracleDriver";
    /**
    * Initial url fragment
    */
    private String url = "jdbc:oracle:thin:@";
    /**
    * Standard Oracle listener port
    */
    private String port = "1521";
    /**
    * Oracle style of calling a stored procedure
    */
    private String oracleQuery = "begin ? := sp_get_stocks(?); end;";
    /**
    * JDBC style of calling a stored procedure
    */
    private String genericQuery = "{ call ? := sp_get_stocks(?) }";
    /


Ïà¹ØÎĵµ£º

Java¸ß¼¶Ó¦Óÿª·¢¾­Ñé·ÖÏí

JavaµÄÓŵãÓУº ¿çƽ̨ÐÔºÜÇ¿µÄ£¬Ò»´Î±àÒëµ½´¦ÔËÐУ¬Ò»±ß±àÒëÒ»±ßÖ´ÐУ¬ ²»Êܲ¡¶¾µÄ¸ÉÈÅ¡£µ«ÊÇÃÀÖв»×㣬ÔËÐÐËٶȱÈC£¬C++ µÈÓïÑÔÂý£¬ ·ÃÎÊÓ²¼þµ×²ã±È²»ÉÏC++£¬C£¬Ò»Ð©Ó¦ÓÃÐèÇóÈ´ÐèÒªÖ´Ðд¿ Java ³ÌÐòÎÞ·¨Íê³ÉµÄһЩÈÎÎñ¡£Îª´ËSUN¹«Ë¾ÎªÁËÍ»ÆÆJAVAµÄÆ¿¾±£¬ ¾ÍÒýÈëÁËJNI µÄ×÷Ó㬠JNI¾ÍÊÇÄܹ»¼æÈÝC£¬Ñﳤ±Ü¶Ì£¬ ¿ìËٵķÃÎÊÓ² ......

Javaѧϰ֮·

JAVAÊÇÒ»ÖÖÆ½Ì¨£¬Ò²ÊÇÒ»ÖÖ³ÌÐòÉè¼ÆÓïÑÔ£¬ÈçºÎѧºÃ³ÌÐòÉè¼Æ²»½ö½öÊÊÓÃÓÚJAVA£¬¶ÔC++µÈÆäËû³ÌÐòÉè¼ÆÓïÑÔÒ²Ò»Ñù¹ÜÓá£Óбà³Ì¸ßÊÖÈÏΪ£¬JAVAÒ²ºÃCÒ²ºÃûʲô·Ö±ð£¬ÄÃÀ´¾ÍÓá£ÎªÊ²Ã´ËûÃÇÄÜ´ïµ½Èç´Ë¾³½ç£¿ÎÒÏëÊÇÒòΪ±à³ÌÓïÑÔÖ®¼äÓй²Í¨Ö®´¦£¬Áì»áÁ˱à³ÌµÄ¾«Ë裬×ÔÈ»Äܹ»×öµ½Ò»Í¨°Ùͨ¡£ÈçºÎѧϰ³ÌÐòÉè¼ÆÀíËùµ±È»Ò²ÓÐÐí¶à¹²Í¨µÄµØ·½ ......

¡¶JavaÃæÏò¶ÔÏó±à³Ì¡·Ñ§Ï°±Ê¼Ç18

 1.FileÀàΪ¹ÜÀíÎļþºÍĿ¼ÌṩÁË·½·¨£¬Æä¶ÔÏó±íʾһ¸öÎļþ»òÕßĿ¼¡£ËüÌṩÁËÈô¸É·½·¨¶ÔÎļþ»òÎļþ¼Ð½øÐвÙ×÷¡£ÆäÖеÄlist()·½·¨ºÍlistFiles()·½·¨¿ÉÒÔÆðµ½¶¨Î»Ìض¨ÎļþµÄ×÷Óá£
2.ObjectÀ࣬ÊÇËùÓÐJavaÀàµÄ׿ÏÈ£¬ÈôÒ»¸öÀàÉùÃ÷ʱûÓаüº¬extends¹Ø¼ü×Ö£¬ÔòÆäÖ±½Ó¼Ì³ÐÓÚObjetcÀà¡£ÆäÖÐÓÐÐí¶àÖØÒª·½·¨£º
equals(),not ......

OracleÖеÄNullÖµ½âÎö

         ÓÐÈË×ܽáÁËÊý¾Ý¿âÖÐNullÖµµÄ¸ÅÄ±È½Ï¾«Á¶£¬ÕªÂ¼ÈçÏ£º
NullÊÇÊý¾Ý¿âÖÐÌØÓеÄÊý¾ÝÀàÐÍ£¬µ±Ò»Ìõ¼Ç¼µÄij¸öÁÐΪNull£¬Ôò±íʾÕâ¸öÁеÄÖµÊÇδ֪µÄ¡¢ÊDz»È·¶¨µÄ¡£¼ÈÈ»ÊÇδ֪µÄ£¬¾ÍÓÐÎÞÊýÖֵĿÉÄÜÐÔ¡£Òò´Ë£¬Null²¢²»ÊÇÒ»¸öÈ·¶¨µÄÖµ¡£
ÕâÊÇNullµÄÓÉÀ´¡¢Ò²ÊÇNullµÄ»ù´¡£¬ËùÓк ......

Oracle ±íÁ¬½Ó·½Ê½·ÖÎö

Ò» ÒýÑÔ
Êý¾Ý²Ö¿â¼¼ÊõÊÇĿǰÒÑÖªµÄ±È½Ï³ÉÊìºÍ±»¹ã·º²ÉÓõĽâ¾ö·½°¸£¬ÓÃÓÚÕûºÍµçÐÅÔËÓªÆóÒµÄÚ²¿ËùÓзÖÉ¢µÄԭʼҵÎñÊý¾Ý£¬²¢Í¨¹ý±ã½ÝÓÐЧµÄÊý¾Ý·ÃÎÊÊֶΣ¬¿ÉÒÔÖ§³ÖÆóÒµÄÚ²¿²»Í¬²¿ÃÅ£¬²»Í¬ÐèÇ󣬲»Í¬²ã´ÎµÄÓû§ËæÊ±»ñµÃ×Ô¼ºËùÐèµÄÐÅÏ¢¡£Êý¾Ý²Ö¿âϵͳÐèÒªÄܹ»¼°Ê±µØ×·×ٺͷÖÎö´óÁ¿µÄÀúÊ·Êý¾Ý£¬²¢Äܹ»¼°Ê±×ö³ö·ÖÎöºÍÔ¤²â£¬Òò´ËÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ