zoukankan      html  css  js  c++  java
  • 更新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

  • 相关阅读:
    公式编辑器mathtype中一些符号显示方框的解决方法
    I got my first job
    我的第二个面试通知
    清空visual studio2010的查找历史
    King Back
    IIS中“使用 XSL 样式表无法查看 XML 输入”问题的解决
    JDBC 各种连接方式[转载]
    力扣每日刷题(1)
    力扣每天刷题(3)
    力扣每天刷题(2)
  • 原文地址:https://www.cnblogs.com/likehua/p/2074459.html
Copyright © 2011-2022 走看看