Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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(?) }";
    /


Ïà¹ØÎĵµ£º

oracle ±í¿Õ¼ä²Ù×÷

oracle±í¿Õ¼ä²Ù×÷Ïê½â
  1
  2
  3×÷Õߣº   À´Ô´£º    ¸üÐÂÈÕÆÚ£º2006-01-04 
  5
  6 
  7½¨Á¢±í¿Õ¼ä
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

ÎÒµÄjavaѧϰÈÕ¼Ç

  Ôڴ󲿷Ö×ÔѧµÄÇé¿öÏ£¬Ñ§Ï°javaÒÑ¿ìÓÐÒ»ÄêÁË£¬×î½ü¿´ÁËÒ»ÏÂjdkÖÐdemoϵÄClockС³ÌÐò£¬ÔÚÎÂÏ°ÁËÒ»ÏÂAppletµÄͬʱ£¬Ò²Ñ§µ½Á˲»ÉÙж«Î÷¡£Ê×ÏÈ£¬AppletµÄ»ù±¾¹Ç¼ÜÊÇÓÉ£ºinit(),start(),stop(),destroy(),paint(Graphics g),repaint()ºÍupdate()Õ⼸¸ö·½·¨¹¹³ÉµÄ¡£
  init()ÓÃÀ´³õʼ»¯ÊµÀý£¬start()ÓÃÀ´Æ𶯳ÌÐò ......

JAVAÖÐÕýÔò±í´ïʽµÄÓ¦ÓÃ2

 public static void main(String[] args)
    {
        InputStream is = CommonUtil.getStream("http://wz.csdn.net/");
        String regex = "(?<=href=\")[^\"]*";//²éÕÒÍøÒ³ÖÐËù ......

ORACLEÁÙʱ±íºÍSQLSERVERÁÙʱ±íÒìͬ

 SQL SERVERÁÙʱ±í
Ò²¿ÉÒÔ´´½¨ÁÙʱ±í¡£ÁÙʱ±íÓëÓÀ¾Ã±íÏàËÆ£¬µ«ÁÙʱ±í´æ´¢ÔÚ tempdb ÖУ¬µ±²»ÔÙʹÓÃʱ»á×Ô¶¯É¾³ý¡£
Óб¾µØºÍÈ«¾ÖÁ½ÖÖÀàÐ͵ÄÁÙʱ±í£¬¶þÕßÔÚÃû³Æ¡¢¿É¼ûÐԺͿÉÓÃÐÔÉϾù²»Ïàͬ¡£±¾µØÁÙʱ±íµÄÃû³ÆÒÔµ¥¸öÊý×Ö·ûºÅ (#) ´òÍ·£»
ËüÃǽö¶Ôµ±Ç°µÄÓû§Á¬½ÓÊǿɼûµÄ£»µ±Óû§´Ó Microsoft? SQL Server? 2000 ʵÀý¶Ï ......

OracleÖеÄNullÖµ½âÎö

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