J2EEÓ¦ÓÃÖÐÓëOracleÊý¾Ý¿âµÄÁ¬½Ó
ÔÚJ2EEÓ¦ÓóÌÐò¿ª·¢ÖУ¬Ó¦ÓóÌÐòÓëÊý¾Ý¿âÁ¬½ÓµÄ½¨Á¢ÊÇÎÒÃǾ³£Óöµ½µÄÎÊÌâÖ®Ò»¡£ÔÚÕâÀïÎÒÖ÷Ҫ̸̸ÔÚ±¾µØÓ¦ÓóÌÐòÖÐͨ¹ýOCI·½Ê½¡¢thin·½Ê½ºÍJdbcOdbcÇÅ·½Ê½Á¬½ÓOracleÊý¾Ý¿â£¬ÔÚiPlanet Application Server 6.5ºÍSun Java System Application Server 7ÖжÔOracleÊý¾Ý¿âÁ¬½Ó³ØµÄÅäÖÃÒÔ¼°Ó¦ÓÃÖÐÈçºÎ´ÓÁ¬½Ó³ØÖлñµÃÁ¬½Ó
Ò»¡¢±¾µØÍ¨¹ýJDBC»ñµÃOracleÊý¾Ý¿âÁ¬½Ó
ͨ¹ýJDBC»ñµÃOracleÊý¾Ý¿âÁ¬½Ó£¬ÓÐÈýÖÖ·½Ê½£ºOCI·½Ê½¡¢thin·½Ê½ºÍJdbcOdbcÇÅ·½Ê½¡£OCI·½Ê½ÒÀÀµÓÚ±¾µØµÄ¶¯Ì¬Á´½Ó¿â£¬Èç¹ûÔÚ±¾µØ°²×°ÁËOracleÊý¾Ý¿â¿Í»§¶Ë¿ÉÒÔ²ÉÓø÷½Ê½£»¶øthin·½Ê½Îª´¿javaµÄÊý¾Ý¿âÁ¬½Ó·½Ê½£»JdbcOdbcÇÅ·½Ê½ÒÀÀµÓÚ±¾µØODBCÊý¾Ý¿âÔ´µÄÅäÖã¬ÕâÖÖ·½Ê½Ò»°ã²»Ì«±»²ÉÓá£
1¡¢OCI·½Ê½
ÏÈÔÚ±¾µØ°²×°Oracle¿Í»§¶Ë£¬°²×°ÍêÖ®ºó£¬ÔÚ°²×°µÄ·¾¶ÖпÉÒÔÕÒµ½…/jdbc/lib/classes12.zipÎļþ£¬ÎÒÃÇÔÚ»·¾³±äÁ¿classpathÖÐÉèÖÃclasses12.zipËùÔڵķ¾¶¡£
È»ºóͨ¹ýÒÔϵÄÊý¾Ý¿âÁ¬½ÓÀ࣬ÔÚ±¾µØÍ¨¹ýOCI·½Ê½»ñµÃOracleÊý¾Ý¿âÁ¬½Ó
/**
* ÔÚ±¾µØ»ñµÃÊý¾Ý¿âÁ¬½Ó
*/
package com.j2ee.db;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
import javax.naming.*;
/**
* ͨ¹ýOCI·½Ê½»ñµÃOracleÊý¾Ý¿âÁ¬½Ó
*/
public class DbConnection
{
final static String sDBDriver = "oracle.jdbc.driver.OracleDriver";
final static String sConnStr = "jdbc:oracle:oci8:sr/sr@ora199";
/**
*
*/
public DbConnection()
{
}
/**
* »ñµÃOracleÊý¾Ý¿âÁ¬½Ó
*/
public java.sql.Connection connectDbByOci()
{
java.sql.Connection conn=null;
try
{
Class.forName(sDBDriver);
conn = DriverManager.getConnection(sConnStr);
}
catch (Exception e)
{
System.out.println("ERROR:"+e.getMessage());
}
return conn;
}
}
ÔÚÁ¬½Ó×Ö·û´® "jdbc:oracle:oci8:sr/sr@ora199" ÖУ¬"sr/sr"ΪOracleÓû§µÄÓû§ÃûºÍ¿ÚÁ"ora199"ΪÊý¾Ý¿â·þÎñÃû¡£
2¡¢thin·½Ê½
Ïȵ½Oracle¼¼ÊõÍø£¨http://otn.oracle.com/global/cn/software/tech/java/sqlj_jdbc/index.html£©ÏÂÔØOracle JDBC Drivers£¬Í¬ÑùµØ½«ÏÂÔØºóµÄzipÎļþµÄ·¾¶ÉèÖÃÔÚ»·¾³±äÁ¿classpath¡£
È»ºóͨ¹ýÒÔϵÄÊý¾Ý¿âÁ¬½ÓÀ࣬ÔÚ±¾µØÍ¨¹ýthin·½Ê½»ñµÃOracleÊý¾Ý¿âÁ¬½Ó¡£
/**
* ÔÚ±¾µØ»ñµÃÊý¾Ý¿âÁ¬½Ó
*/
package com.j2ee.db;
import java.
Ïà¹ØÎĵµ£º
TO_DATE¸ñʽ
Day:
dd number 12
dy abbreviated fri
day spelled out friday
ddspth spelled out, ordinal twelfth
Month:
mm number 03
mon abbreviated mar
month spelled out march
Year:
yy two digits 98
yyyy four digits 1998
24Сʱ¸ñʽÏÂʱ¼ä·¶Î§Îª£º 0:00:00 - 23:59:59....
12Сʱ¸ ......
shutdown immediate
Ç¿Áв»½¨ÒéתΪ·Ç¹éµµÄ£Ê½
startup mount
alter database noarchivelog
alter database open
·Ç¹éµµ×ª¹éµµ
startup mount
alter database archivelog
alter database open
Ôڹ鵵ÈÕ־ģʽÏ£¬ÓпÉÄÜ»áÓöµ½¹éµµÈÕÖ¾´óС³¬¹ý×î´óÖµ¶ø³öÏÖÌÖÑáµÄORA-00257´íÎó£¬Ç°ÃæËµÁËÈçºÎ°Ñ¹éµµÈÕÖ¾¿Õ¼ä±ä´ó¡£¶ ......
ORACLEÀïËøÓÐÒÔϼ¸ÖÖģʽ:
0£ºnone
1£ºnull ¿Õ
e.g. 1¼¶ËøÓУºSelect£¬ÓÐʱ»áÔÚv$locked_object³öÏÖ¡£
2£ºRow-S Ðй²Ïí(RS)£º¹²Ïí±íËø£¬sub share
e.g. 2¼¶ËøÓУºSelect for update,Lock For Update,Lock Row Share
  ......
Ò»¡¢ÉèÖóõʼ»¯²ÎÊý job_queue_processes
¡¡¡¡sql> alter system set job_queue_processes=n;£¨n>0£©
¡¡¡¡job_queue_processes×î´óֵΪ1000
¡¡¡¡
¡¡¡¡²é¿´job queue ºǫ́½ø³Ì
¡¡¡¡sql>select name,description from v$bgprocess;
¡¡¡¡
¡¡¡¡¶þ£¬dbms_job package Ó÷¨½éÉÜ
¡¡¡¡°üº¬ÒÔÏÂ×Ó¹ý³Ì£º
¡¡¡¡
¡¡ ......
·ÖÒ³µÄ×ÚÖ¼ÊÇ¿ØÖƲéѯ³öÀ´µÄÊý¾Ý¸öÊý£¬ÏÂÃæÕâÌõÓï¾ä¶ÔÓÚOracle·ÖÒ³ÒѾ×ã¹»ÁË¡£
£¨×¢£º¸ÃÓï¾äÖ»ÄÜÓÃÓÚOracle£©
SELECT * from (SELECT temp.*, ROWNUM RN from (SELECT * from USERS ORDER BY ID DESC) temp) WHERE RN > 0 AND RN <= 10
SELECT *
from (SELECT AA.*, ROWNUM RN ......