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

JAVAʵÏÖOracleÊý¾Ý¿âµÄÊý¾ÝµÄ·ÖÒ³ÏÔʾ

 
×î½üѧÁËservletºÍoracle£¬Ò²¾Í°ÑËûÃǽáºÏÏ£¬×ö¸ö·ÖÒ³µÄÒ³Ãæ³öÀ´¡£ËãÊÇÒ»ÖÖ¸´Ï°°É¡£
1.Ê×ÏÈÊÇoracleµÄ·ÖÒ³ÏÔʾSQLÓï¾ä£º
select * from(select a.*, rownum  rn from (select * from Person) a where  rownum <= MaxNum) where rn > MinNum;
2.È»ºóÔÚjavaÖУ¬Á¬½ÓÊý¾Ý¿âµÄÓï¾äÓÐÏÂÃ漸¶Î£º
//¼ÓÔØÇý¶¯
Class.forName("oracle.jdbc.driver.OracleDriver");
//´ò¿ªÊý¾Ý¿â
Connection ct = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:myora1", "sys as sysdba", "abc");
/*
*Õâ¸öº¯ÊýÓÐÈý¸ö²ÎÊý 
*µÚÒ»¸ö²ÎÊý jdbc:oracle:thin@ + IPµØÖ· + ¶Ë¿ÚºÅ + Êý¾Ý¿âÃû
*µÚ¶þ¸ö²ÎÊý Óû§Ãû
*µÚÈý¸ö²ÎÊý ÃÜÂë
*/
//´´½¨Á¬½ÓÊý¾Ý¿âµÄ»á»°
Statement sm = ct.createStatement();
//ÉèÖÃSQLÓï¾ä
ResultSet rs = sm.executeQuery("............");
3.É趨·ÖÒ³µÄËĸö¹Ø¼üÖµ
int pageSize = 5;   //Ò»Ò³ÏÔʾµÄÌõÄ¿Êý    ×Ô¼ºÉ趨
int pageNow = 1;   //µ±Ç°µÄÒ³Êý   ³õʼֵΪ1
int rowCount = 0;   //Ò»¹²µÄ¼Ç¼Êý
int pageCount = 0;   //Ò»¹²µÄÒ³Êý
µÚ¶þ¸öÊÇÓû§Ñ¡¶¨³öÀ´µÄ£¬ËùÒÔ¼ÓÉÏ
String id = (String)req.getParameter("id");
if(!(id == null || id.equals("")))
{
pageNow = Integer.parseInt(id);
}
ÏÂÃæÁ½¸öÊÇÒª¼ÆËã³öÀ´µÄ~
rowCount:
ResultSet rst = sm.executeQuery("select count(*) from Person");
while(rst.next())
{
rowCount = rst.getInt(1);
}
pageCount:
pageCount = (rowCount % pagesize == 0) ? rowCount / pageSize : rowCount / pageSize + 1;
OK,»ù±¾ÒªËؽ²ÍêÁË£¬ÏÂÃæÉÏÍêÕûCode£º
package com.testing;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet


Ïà¹ØÎĵµ£º

an example to insert data into Oracle Clob

 Step1. Insert empty_clob() into the Clob column of Oracle
Step2. Set autocommit to false
Step3. Select Clob as oracle.sql.CLOB from database
Step4. Insert String into Clob
Step5. Commit
Example:
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.OracleResultSet;
......

ORACLEÖÐÈçºÎ²éÕÒÌض¨¶ÔÏóÖеÄÎı¾ÄÚÈÝ~

SQL> select dbms_metadata.get_ddl('PROCEDURE','PRO2','SCOTT') text from dual;
TEXT
----------------------------------------
CREATE OR REPLACE PROCEDURE "SCOTT"."P
RO2"
is
begin
dbms_output.put_line('wangpeng up');
end;
SQL> select dbms_metadata.get_ddl('PROCEDURE','PRO1','SCOTT') te ......

oracleµ¥Ðк¯Êý

µ¥Ðк¯Êý:
º¯ÊýÀà±ð:
    µ¥ÐÐ:·µ»Øµ¥¸ö½á¹û:substr,length
    ¶àÐÐ:·µ»Ø¶à¸ö½á¹û,any,all
µ¥ÐеķÖÀà:
    ×Ö·ûÀ࣬ÈÕÆÚÀ࣬Êý×ÖÀ࣬ת»»À࣬ͨÓÃÀà
1.×Ö·ûÀà
ת»»´óСд:
lower:ת»»ÎªÐ¡Ð´
Select ENAME,LOWER(ENAME) from EMP
upper:ת»»Îª´óд
Select upper( ......

Oracle´æ´¢¹ý³Ì·ÖÒ³

תÔØ
from: http://cid-4e5d038451e31a25.spaces.live.com/blog/cns!4E5D038451E31A25!140.entry
create or replace procedure P_QuerySplit(
      sqlscript varchar2,     --±íÃû/SQLÓï¾ä
      pageSize integer,     ......

¡¶Effective javaÖÐÎĵÚ2°æ¡·¶ÁÊé±Ê¼Ç1

µÚ2Ìõ£ºÓöµ½¶à¸ö¹¹ÔìÆ÷²ÎÊýʱҪ¿¼ÂÇÓù¹½¨Æ÷
ij¸öÀàµÄÊôÐԽ϶࣬³õʼ»¯µÄʱºòÓÖÓÐһЩÊDZØÐë³õʼ»¯µÄ£¬¶øÇÒÀàÐÍÓÐÐÎͬ£¬
±ÈÈçnew Contact("ÐÕÃû","ÏÔʾÃû","ÊÖ»úºÅ","·ÉÐźÅ","ËùÔÚµØ",ÄêÁä,ÐÔ±ð);
Ç°5¸öÊôÐÔÊÇString ÀàÐÍ£¬ºó2¸öÊÇintÀàÐÍ£¬ÔÚÌîд¹¹Ôì·½·¨µÄʱºòºÜÈÝÒ×Ìîд´í룬»òÕßÉÙÌîд£¬»òÕߵߵ¹ÁËÊôÐÔ£¬
ÈçÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ