易截截图软件、单文件、免安装、纯绿色、仅160KB

JDBC存取ORACLE大型数据对象LOB几种情况的示范类

      import Java.io.*;
  import java.util.*;
  import java.sql.*;
  public class LobPros
  {
  /**
  * Oracle驱动程序
  */
  private static final String DRIVER = "oracle.jdbc.driver.OracleDriver";
  /**
  * ORACLE连接用URL
  */
  private static final String URL = "jdbc:oracle:thin:@test2000:1521:orac";
  /**
  * 用户名
  */
  private static final String USER = "user";
  /**
  * 密码
  */
  private static final String PASSWord = "pswd";
  /**
  * 数据库连接
  */
  private static Connection conn = null;
  /**
  * SQL语句对象
  */
  private static Statement stmt = null;
  /**
  * @roseuid 3EDA089E02BC
  */
  public LobPros()
  {
  }
  /**
  * 往数据库中插入一个新的CLOB对象
  *
  * @param infile - 数据文件
  * @throws java.lang.Exception
  * @roseuid 3EDA04A902BC
  */
  public static void clobInsert(String infile) throws Exception
  {
  /* 设定不自动提交 */
  boolean defaultCommit = conn.getAutoCommit();
  conn.setAutoCommit(false);
  try {
  /* 插入一个空的CLOB对象 */
  stmt.executeUpdate("INSERT INTO TEST_CLOB VALUES ('111', EMPTY_CLOB())");
  /* 查询此CLOB对象并锁定 */
  ResultSet rs = stmt.executeQuery("SELECT CLOBCOL from TEST_CLOB WHERE ID='111' FOR UPDATE");
  while (rs.next()) {
  /* 取出此CLOB对象 */
  oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CLOBCOL");
  /* 向CLOB对象中写入数据 */
  BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
  BufferedReader in = new BufferedReader(new FileReader(infile));
  int c;
  while ((c=in.read())!=-1) {
  out.write(c);
  }
  in.close();
  out.close();
  }
  /* 正式提交 */
  conn.commit();
  } catch (Exception ex) {
  /* 出错回滚 */
  conn.rollback();
  throw ex;
  }
  /* 恢复原提交状态 */


相关文档:

Oracle:查找表的主键,外键,唯一性约束,索引

束,索引
1、查找表的所有索引(包括索引名,类型,构成列):
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表
2、查找表的主键(包括名称,构成列):
select cu.* from user_cons_columns cu ......

Oracle SQL实例

1。select * from a where a.rowid=(select min(b.rowid) from b where a.id=b.id);
create test1(
nflowid number primary key, 
ndocid number,
drecvdate date);
insert into test1 values (1, 12301, sysdate) ;
insert into test1 values (2, 12301, sysdate);
select * from test1 order by drecvdate:
......

在Oracle中实现数据库的复制


在Internet上运作数据库经常会有这样的需求:把遍布全国各城市相似的数据库应用统一起来,一个节点的数据改变不仅体现在本地,还反映到远端。复制技术给用户提供了一种快速访问共享数据的办法。
一、实现数据库复制的前提条件
1、数据库支持高级复制功能
您可以用system身份登录数据库,查看v$option视图,如果其中Adv ......

oracle日期函数

oracle日期函数,
      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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号