• 更新oracle数据库中xml数据


    //更新图层元数据
     public  static  boolean  updateLayerMetadataByID(DataSource ds,String id,String xml)throws SQLException,ClassNotFoundException{
      boolean  flag=false;
      Connection con=null;
      try{
       String metadataTableName=DBUtil.getLayerMetadataTableName(ds);
       StringBuffer buffer=new StringBuffer("Update ");
       buffer.append(metadataTableName);
       buffer.append(" SET DATACOL = ? WHERE RECORDID = ?");
    //   buffer.append(id);
    //   buffer.append("'");
       con=DBUtil.getConnection(ds);
       logger.info("excute sql:"+buffer.toString());
       OraclePreparedStatement ste=(OraclePreparedStatement)con.prepareStatement(buffer.toString());
       XMLType xmltype=XMLType.createXML(con, xml);
       ste.setObject(1, xmltype);
       ste.setString(2, id);
       //boolean result = false;
       //try{
        ste.execute();
        flag = true;
        //_log.info("execute sql : " + sql.toString() + " successful.");
       //} finally {
        if(ste != null) {
         ste.close();
         ste = null;
        }
       //}    
      }catch(ClassNotFoundException e){
       flag=false;
       throw new ClassNotFoundException(e.getMessage());
      }catch(SQLException e){
       flag=false;
       throw new SQLException(e);
      }finally{
       try{
       DBUtil.closeConnection(con);
       }
       catch(SQLException e){
        flag=false;
        throw new SQLException(e);
       };
       
      }
      return flag;
      
     };

    转载请注明出处,欢迎交流!http://www.cnblogs.com/likehua

  • 相关阅读:
    运维
    Linux学习
    .net Core使用Knife4jUI更换Swagger皮肤
    VS Code中使用live Server
    去重复保留一条数据
    sql server 索引检测
    Centos 7 .Net core后台守护进程Supervisor教程
    鼠标移动 在左边放大图片
    根据配置表将数据从A表转入B表
    JS替换或切割
  • 原文地址:https://www.cnblogs.com/likehua/p/2074459.html
Copyright © 2020-2023  润新知