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

java jdbc µ÷Óà oracle´æ´¢¹ý³Ì ·µ»ØÓαê

1.´´½¨²âÊÔ±í
create table users(
userid int primary key,
username varchar2(20),
userpwd  varchar2(20)
);
insert into users values(1,'test','test');
insert into users values(2,'test','test');
insert into users values(3,'test','test');
insert into users values(4,'test','test');
insert into users values(5,'test','test');
insert into users values(6,'test','test');
insert into users values(7,'test','test');
2.´´½¨´æ´¢¹ý³Ì
´´½¨°ü
create or replace package pkg_test
as
  type cursor0 is ref cursor;
  procedure get(p_id int,p_rc out cursor0);
end pkg_test;
 
´´½¨°üµÄÄÚÈÝ
create or replace package body pkg_test as
  procedure get(p_id int, p_rc out cursor0) is
  begin
    dbms_output.put_line(p_id);
    open p_rc for
      select userid, username, userpwd from users;
  end get;
end pkg_test;
3.javaµ÷ÓÃ
package com.wei;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
/***
 *
 * ²âÊÔ jdbc Á¬½Ó oracle ´æ´¢¹ý³Ì ·µ»ØÓαê
 *
 * @author wei
 *
 */
public class Main {
 public static void main(String[] args) {
  try {
   DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
   Class.forName("oracle.jdbc.driver.OracleDriver");
   String url = "jdbc:oracle:thin:@127.0.0.1:1521:wei";
   String username = "test";
   String password = "admin";
   Connection conn = DriverManager.getConnection(url, username,
     password);
   String sql = "{call pkg_test.get(?,?)}";
   CallableStatement cstmt = conn.prepareCall(sql);
   cstmt.setInt(1, 1);
   cstmt.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
  &


Ïà¹ØÎĵµ£º

Oracle С֪ʶ ÂýÂý¸üÐÂ

1. ÿÌìµÄ8£º00µ½23£º00ÿ¸ô5·ÖÖÓÖ´ÐÐÒ»¸ösqlÓï¾äµÄJOB
     --½¨Á¢Ò»¸ö´æ´¢¹ý³Ì
CREATE OR REPLACE PROCEDURE p_jobtest IS
  v_hh VARCHAR2(2);
BEGIN
  v_hh := to_char(SYSDATE, 'hh24');
  IF v_hh >= '08' AND v_hh <= '22' THEN
    --ÄãµÄsqlÓï¾ä ......

oracle ´æ´¢¹ý³ÌµÄ»ù±¾Óï·¨ ¼°×¢ÒâÊÂÏî

oracle ´æ´¢¹ý³ÌµÄ»ù±¾Óï·¨
1.»ù±¾½á¹¹
CREATE OR REPLACE PROCEDURE ´æ´¢¹ý³ÌÃû×Ö
(
    ²ÎÊý1 IN NUMBER,
    ²ÎÊý2 IN NUMBER
) IS
±äÁ¿1 INTEGER :=0;
±äÁ¿2 DATE;
BEGIN
END ´æ´¢¹ý³ÌÃû×Ö
2.SELECT INTO STATEMENT
  ½«select²éѯµÄ½á¹û´æÈëµ½±äÁ¿ÖУ¬¿ÉÒÔͬʱ½«¶à¸ö ......

oracle°üºÍREF CURSOR

     Ê×ÏÈ£¬ÐèÒªÖØÐÂÕûÀíÒ»ÏÂÏà¹Ø¸ÅÄoracleÊý¾Ý¿âÖк¯ÊýµÄ×÷Óã¬ÊÇÖ»Äܱ»±ðÈ˵÷Ó㬴洢¹ý³Ì¿ÉÒÔµ¥¶ÀÖ´ÐУ¬²¢ÇÒ¿ÉÒÔµ÷Óô洢¹ý³Ì£¬¶ø°üµÄ×÷Óðü¿ÉÒÔ½«ÈκγöÏÖÔÚ¿éÉùÃ÷µÄÓï¾ä ( ¹ý³Ì , º¯Êý , Óαê , Óαê , ÀàÐÍ , ±äÁ¿ ) ·ÅÓÚ°üÖÐ , Ï൱ÓÚÒ»¸öÈÝÆ÷ . ½«ÉùÃ÷Óï¾ä·ÅÈë°üÖеĺô¦ÊÇ : Óû§¿ÉÒÔ´ÓÆäË ......

oracle RACµÄ½ø³ÌÃÇ

GSD global services daemon (GSD)
ÓëracµÄ¹ÜÀí¹¤¾ßdbca srvctl
oem½øÐн»»¥£¬ÓÃÀ´Íê³ÉʵÀýµÄÆô¶¯¹Ø±ÕµÈ¹ÜÀíÈÎÎñ¡£
ΪÁ˱£Ö¤ÕâЩ¹ÜÀí¹¤¾ßÔËÐÐÕý³£±ØÐëÔÚËùÓеĽڵãÉÏÏÈstart
gsd,²¢ÇÒÒ»¸öGSD½ø³ÌÖ§³ÖÔÚ
Ò»¸ö½ÚµãµÄ¶à¸örac.gsd½ø³ÌλÓÚ$ORACLE_HOME/binĿ¼Ï£¬ÆälogÎļþ
Ϊ$oracle_home
/srvm/log/gsdaemon.log
À ......

³£¼ûOracle HINTµÄÓ÷¨

¡¡1. /*+ALL_ROWS*/
¡¡¡¡±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
¡¡¡¡ÀýÈç:
¡¡¡¡SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
¡¡¡¡2. /*+FIRST_ROWS*/
¡¡¡¡±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÏìӦʱ¼ä,ʹ×ÊÔ´ÏûºÄ×îС»¯.
¡¡¡¡ÀýÈç ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ