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

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;
import oracle.sql.CLOB;
public class TestOracleClob implements Serializable{
public static void main(String[] args)
{

//create table test (id integer,content clob);
System.out.println("-------------------insert -----------------");
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection ("oracle server",
"loginid", "loginpassword");
//Class.forName("oracle.jdbc.driver.OracleDriver");

con.setAutoCommit(false);
//Ok 1
String sql="insert into test values(1,empty_clob())";
Statement stmt=con.createStatement();
ResultSet
rs=stmt.executeQuery(sql);
System.out.println("-------------------insert -----------------");
String sqll="select content from test where id=1 for update";
ResultSet
rss=stmt.executeQuery(sqll);

if(rss.next()){
//CLOB clob = ((OracleResultSet)rss).getCLOB(1);
oracle.sql.CLOB clob= (oracle.sql.CLOB)rss.getClob("content");
clob.putString(1,"here is a string which contains more than 4000 character");
sql="update test set content=? where id=1";
PreparedStatement
pstmt=con.prepareStatement(sql);
pstmt.setClob(1,clob);
pstmt.executeUpdate();
pstmt.close();
}
con.commit();

//Ok 2
//String sql1="insert into test values(2,empty_clob())";
//ResultSet rs3=stmt.executeQuery(sql1);
String sql12="insert into test values(?,?)";
PreparedStatement
pstmt1=con.prepareStatement(sql12);
pstmt1.setInt(1,2);
pstmt


Ïà¹ØÎĵµ£º

¼Ç¼һЩsqlÓï¾äoracleµÄ

 select d.code,d.name, sum(w.weight) weight,round(avg(w.price),2) price,sum(w.money) money
from weight_info w left outer join t_dict d on w.productcode=d.code left outer  join t_balancecode b on w.balancecode=b.balancecode where 1=1 and w.operdate>TO_TIMESTAMP('2009-11-2 04:12:32.0', ' ......

Oracle Êý¾Ý¿â¼àÌýÅäÖÃ


Ò»¡¢¼àÌýÆ÷(LISTENER)
¡¡¡¡¼àÌýÆ÷ÊÇOracle»ùÓÚ·þÎñÆ÷¶ËµÄÒ»ÖÖÍøÂç·þÎñ£¬Ö÷ÒªÓÃÓÚ¼àÌý¿Í»§¶ËÏòÊý¾Ý¿â·þÎñÆ÷¶ËÌá³öµÄÁ¬½ÓÇëÇó¡£¼ÈÈ»ÊÇ»ùÓÚ·þÎñÆ÷¶ËµÄ·þÎñ£¬ÄÇôËüÒ²Ö»´æÔÚÓÚÊý¾Ý¿â·þÎñÆ÷¶Ë£¬½øÐмàÌýÆ÷µÄÉèÖÃÒ²ÊÇÔÚÊý¾Ý¿â·þÎñÆ÷¶ËÍê³ÉµÄ¡£
 
¶þ¡¢±¾µØ·þÎñÃû(Tnsname)
¡¡¡¡Oracle¿Í»§¶ËÓë·þÎñÆ÷¶ËµÄÁ¬½ÓÊÇͨ¹ý¿Í»§¶ ......

hibernate3 µ÷ÓÃoracle´æ´¢¹ý³ÌµÄ·½·¨

ÅäÖÃÎļþ£º
<hibernate-mapping>
    <class name="vo.SshPost" table="ssh_post" >
     <!-- <cache usage="read-write"/>-->
        <id name="postId" type="java.lang.String">
     ......

oracle Êý¾Ý¿âÀï²é¿´±í¿Õ¼äÊ©ÓÃÇé¿ö

 oracle Êý¾Ý¿âÀï²é¿´±í¿Õ¼äÊ©Óþ°¿ö£»
oracle±í¿Õ¼äµÄʶùÇé¿öÒª³£³£²é¿´£¬Õý³£ÏпձÈÂʹýµÍµÄʱ·Ö¾ÍÓ¦¸Ã˼¿¼Ôö´ó±í¿´¿Õ¼äÁË¡£²é¿´²½ÖèÈç´ÎSQL:
²½Öè1£º
select dbf.tablespace_name,
dbf.totalspace "×ÜÁ¿(M)",
dbf.totalblocks as ×Ü¿éÊý,
dfs.freespace "ÓàÏÂ×ÜÁ¿(M)",
dfs.freeblocks "ÓàÏ¿éÊý",
(dfs.f ......

¹ØÓÚoracleËÀËø

 Èç¹û½ö½öÊÇlock£¬ÒÔÏÂÓï¾ä¿ÉÒÔ·¢ÏÖËùÓÐÓû§Ëø  :
SELECT s.username,
       decode(l.type, 'TM', 'TABLE LOCK', 'TX', 'ROW LOCK', NULL) LOCK_LEVEL,
       o.owner,
       o.object_name,
 &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ