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
Ïà¹ØÎĵµ£º
Õâ¸öOracleµÄ·ÖÒ³ÏÔʾ¾Ý˵ÊÇ×îÂé·³µÄ£¨MySQL×î¼òµ¥£©£¬µ«ÊÇÕâ¸ö·ÖÒ³ÏÔʾºÜÓÐÓá£ÏÖÔںܶàÍøÕ¾ÉϵÄÌõÄ¿¶¼·Ç³£¶à£¬ÀýÈçÐÂÎÅ£¬¿ÉÄܾ͸ոüеľÍÓÐÉÏ°ÙÌõ£¬ÔÙ¼ÓÉÏÒÔÇ°µÄ£¬Ò»ÕÅÒ³Ãæ¿Ï¶¨¾ÍÊǷŲ»ÏÂÁË£¬ËùÒÔ·ÖÒ³µÄºÃ´¦¾ÍÊÇ¿ÉÒÔ½â¾öÕâ¸öÎÊÌâ¡£
ÏÂÃæÒ»ÅÅÅŵĽÐÄãÑ¡ÔñµÚ¼¸Ò³£¬Ò»Ñ¡Ôñ£¬Ö±½Ó¾ÍÌøµ½ºóÃæµÄ¼¸Ò³È¥ÁË£¬²»ÓÃÕâÑù´ÓÉÏÒ ......
in ÊÇ°ÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ»·£¬Ã¿´ÎloopÑ»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£
in ÊÇ°ÑÍâ±íºÍÄÚ±í×÷hash
Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ»·£¬Ã¿´ÎloopÑ»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔ ......
×î½ü¹«Ë¾´òËãÔÚÏÂÒ»´ú¼Æ·ÑϵͳÀïÃæʹÓÃÄÚ´æÊý¾Ý¿âµÄ¼¼Êõ£¬ËùÒÔ×÷Ϊ¹«Ë¾µÄÉè¼ÆÈËÔ±Ö®Ò»µÄÎÒ£¬ÔÚoracleÍøÉÏÏÂÁ˸öTimesTen£¬°²×°ÔÚÎÒÃǵIJâÊÔ·þÎñÆ÷ÉÏÃæaix5£¬Õâƪ¶ÌÎÄÖ÷ÒªÊÇÎÒ²Ù×÷Êý¾Ý¿âµÄÒ»¸ö±Ê¼Ç£¬ÏÂһƪ´òËã·¢Ò»¸öc³ÌÐòµÄÀý×ÓºÍÎÒ²âÊԵĽá¹û£¬ºóÐø¿ÉÄÜ»¹»áʹÓÃTimesTen cache of oracleÕâ¸ö²úÆ·£¬Â½ÐøÒ²»á·¢Ò»ÏÂÕâ· ......
ת×Ô£ºhttp://blog.csdn.net/wangdongzjk/archive/2005/11/18/532424.aspx
ʹØCUBE ROLLUP GROUPING SETS£¨1£©
ÔÎÄÒý×Ô£º
¾ÛºÏÊÇÊý¾Ý²Ö¿âµÄ»ù´¡¡£ÎªÁËÌá¸ß¾ÛºÏµÄÐÔÄÜ¡£OracleÌṩÁËGroup By Ìõ¿îµÄÀ©Õ¹¡£
1£® CUBE, ROLLUPÀ©Õ¹
2£® 3¸ögroupingº¯Êý
......