zoukankan      html  css  js  c++  java
  • JAVA 中CLOB与Clob有区别

    在JAVA中CLOB与Clob是有区别的类型。

    (oracle.jdbc.internal.OracleCallableStatement)OracleCallableStatement能接收CLOB的数据类型,

    (java.sql.CallableStatement)CallableStatement能接收Clob的数据类型。

    CODE示例

    PACKAGE

    CREATE OR REPLACE PACKAGE BODY cux_test_clob_pkg IS
    PROCEDURE test_lower_clob(p_parameter_id IN NUMBER,
                                        x_out_xml              OUT Clob) IS
            l_temp_str VARCHAR2(32767);
          
            l_temp_clob CLOB;
        BEGIN
          
            dbms_lob.createtemporary(x_out_xml,
                                     TRUE);
            l_temp_str := '<?xml version="1.0" encoding="GBK"?>' || fnd_global.newline;
      
            dbms_lob.writeappend(lob_loc => x_out_xml,
                                 amount  => length(l_temp_str),
                                 buffer  => l_temp_str);
          
        END;
     
    PROCEDURE test_upper_clob(p_parameter_id IN NUMBER,
                                        x_out_xml              OUT CLOB) IS
            l_temp_str VARCHAR2(32767);
          
            l_temp_clob CLOB;
        BEGIN
          
            dbms_lob.createtemporary(x_out_xml,
                                     TRUE);
            l_temp_str := '<?xml version="1.0" encoding="GBK"?>' || fnd_global.newline;
      
            dbms_lob.writeappend(lob_loc => x_out_xml,
                                 amount  => length(l_temp_str),
                                 buffer  => l_temp_str);
          
        END;
     
     
    END;

    //获取CLOB

        private Clob getSuppRegXMLClob(OAPageContext pageContext, OAWebBean webBean,String parameterId){
            Clob clob = null;
            OADBTransaction localOADBTransactionImpl = 
                (OADBTransaction)pageContext.getApplicationModule(webBean).getOADBTransaction();
            OracleCallableStatement localCallableStatement = null;
            LogUtil.of("getSuppRegXMLClob mappingId= "+mappingId+" suppCateMappingId="+suppItemCateMappingId,pageContext).print(pageContext);
            try {
    
                String str = 
                    "begin
    " + 
                    "  cux_test_clob_pkg.test_upper_clob(p_parameter_id => :1,
    " + 
                    "                                                     x_out_xml => :2);
    " + 
                    "end;";
                localCallableStatement = (oracle.jdbc.internal.OracleCallableStatement)localOADBTransactionImpl.createCallableStatement(str, 1);
                localCallableStatement.setObject(1, mappingId);
                localCallableStatement.registerOutParameter(2, OracleTypes.CLOB); 
                localCallableStatement.execute();
                clob = localCallableStatement.getCLOB(2);
           localCallableStatement.close(); 
            } catch (SQLException localException2) {
                clob = null;throw new OAException("getSuppRegXMLClob  cux_test_clob_pkg.test_lower_cloberror!"+localException2.getMessage());            
            } finally {
                try {
                    if (localCallableStatement != null)
                        localCallableStatement.close();
                } catch (Exception localException4) {
                    throw new OAException("getSuppRegXMLClob  error!");
                }
    
            }
            
            return clob;
        }

    //获取Clob

    private CLOB getSuppRegXMLClob(OAPageContext pageContext, OAWebBean webBean,String parameterId){
            CLOB clob = null;
            OADBTransaction localOADBTransactionImpl = 
                (OADBTransaction)pageContext.getApplicationModule(webBean).getOADBTransaction();
            CallableStatement localCallableStatement = null;
            LogUtil.of("getSuppRegXMLClob mappingId= "+mappingId+" suppCateMappingId="+suppItemCateMappingId,pageContext).print(pageContext);
            try {
    
                String str = 
                    "begin
    " + 
                    "  cux_test_clob_pkg.test_upper_clob(p_parameter_id => :1,
    " + 
                    "                                                     x_out_xml => :2);
    " + 
                    "end;";
                localCallableStatement = localOADBTransactionImpl.createCallableStatement(str, 1);
                localCallableStatement.setObject(1, mappingId);
                localCallableStatement.registerOutParameter(2, OracleTypes.CLOB); 
                localCallableStatement.execute();
                clob = localCallableStatement.getClob(2);
           localCallableStatement.close(); }
    catch (SQLException localException2) { clob = null; throw new OAException("getSuppRegXMLClob cux_test_clob_pkg.test_upper_clob!"+localException2.getMessage()); } finally { try { if (localCallableStatement != null) localCallableStatement.close(); } catch (Exception localException4) { throw new OAException("getSuppRegXMLClob error!"); } } return clob; }
  • 相关阅读:
    adb常用命令和工具
    playwright学习记录
    vue,element-ui表格,多个单元格值可修改(点击聚焦后变成input,失去焦点请求保存)
    vue,element-ui表格,合并单元格,如果需要合并的数据隔行,需要重新排列数组
    cas-5.3.x接入REST登录认证,移动端登录解决方案
    企业级cas5.3登录页面修改
    cas实现单点登录mysql,oracle双版本
    Mycat实现MySQL主从复制和读写分离(双主双从)
    IDEA安装插件后默认存放的位置
    值得推荐的Idea十几大优秀插件
  • 原文地址:https://www.cnblogs.com/huanghongbo/p/4884918.html
Copyright © 2011-2022 走看看