Underlying DBMS error [SDE.***]解决思路

针对C#、VS2010、Arcengine10.1环境下,使用Oracle11g数据库进行栅格数据导入SDE时出现的COMException异常,本文详细介绍了异常原因及解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       System.Runtime.InteropServices.COMException (0x80041538): Underlying DBMS error [SDE.*****] 

       异常如下图所示:

       

       一、问题描述:

       1)C#、VS2010、Arcengine10.1、Oracle11g;

       2)程序进行栅格数据导入SDE过程中弹出上述异常;


       二、思考ing:

       从异常信息看是跟数据库相关。当时测试时,导入一个20MB的 tif 影像,导入成功;但导入一个300MB的 tif 影像时,则出现该异常。

       首先推测异常的出现可能跟数据大小有关,进而怀疑数据毕竟多大时才会触发异常,顺着这一思路(即触发异常的数据大小的阈值该是多少)继续思考,对于影像数据而言几百MB只能属于小数据,这么小的数据都能引起异常显然不科学。再结合异常信息中的DBMS,会不会是跟数据库表大小有关?

       将这个猜测在网上查,还真发现关于SDE表空间大小一些相关资料。首先查看了当前SDE表空间中可用空间大小,发现只有几十MB,这就回答了为何20MB的影像可以成功导入,而300MB的影像却导入失败,因为SDE的表空间已经用完,没有足够的空间来装入新数据。

       确定是表空间大小的问题,解决的思路便是给SDE表空间增加空间,网上搜“SDE表空间”之类就能得到很多信息,我采用了让表空间自增的解决方案(也可以用增加SDE表空间的数据文件来解决)。下面是具体解决方法,仅供参考。


       三、解决方法:

       【说明】步骤1)和步骤2)在客户端或服务器查看均可以;步骤3)需要在服务器端进行。步骤2)中得到的FILE_NAME字段的值也指的是服务器端的路径。

       1)查看当前表空间使用情况;(我都是在PLSQL里输入SQL命令查询的,下同)

       

select tablespace_name, sum(bytes)/(1024*1024) as free_space
from dba_free_space 
group by tablespace_name; 
       查询结果如下:

       

       也可以用下面这个SQL语句,都是查看表空间使用情况,下面这个信息更丰富些。

SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE, 
(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE" 
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C 
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;

       2)查找SDE表空间中数据文件的全路径;(第3步会用到)

SELECT * FROM DBA_DATA_FILES t where t.TABLESPACE_NAME = 'SDE';
       
       【注意】这里的FILE_NAME字段的值指的服务器端的路径,在服务器上,定位到该目录下可以找到SDE.DBF文件并查看其大小。


       3)修改SDE表空间为自增长(通过服务器上本地存放文件来设置);

       

ALTER DATABASE DATAFILE 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\SDE.DBF' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
       意思是,把”C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\SDE.DBF“这个文件的自增长设置为100MB,当然这个步幅可以根据自己情况设置。


       至此,修改SDE表空间大小已完成,导入一个较多数据时,可以看到SDE.DBF的大小会相应变化。


       参考资料:http://www.cnblogs.com/Jingkunliu/p/5177954.html   http://blog.sina.com.cn/s/blog_5d32e4930100mqxy.html


       四、总结:

       对比测试出错的地方和测试正确的地方,合理猜测可能出错的原因,进而对其进行验证。确定了原因便可以对症下药,找其解决方法。

       解决方法仅供参考。

Strophe.Builder = function (name, attrs) { // Holds the tree being built. this.nodeTree = this._makeNode(name, attrs); // Points to the current operation node. this.node = this.nodeTree; }; Strophe.Builder.prototype = { /** Function: tree * Return the DOM tree. * * This function returns the current DOM tree as an element object. This * is suitable for passing to functions like Strophe.Connection.send(). * * Returns: * The DOM tree as a element object. */ tree: function () { return this.nodeTree; }, /** Function: toString * Serialize the DOM tree to a String. * * This function returns a string serialization of the current DOM * tree. It is often used internally to pass data to a * Strophe.Request object. * * Returns: * The serialized DOM tree in a String. */ toString: function () { return Strophe.serialize(this.nodeTree); }, /** Function: up * Make the current parent element the new current element. * * This function is often used after c() to traverse back up the tree. * For example, to add two children to the same element * > builder.c('child1', {}).up().c('child2', {}); * * Returns: * The Stophe.Builder object. */ up: function () { this.node = this.node.parentNode; return this; }, /** Function: attrs * Add or modify attributes of the current element. * * The attributes should be passed in object notation. This function * does not move the current element pointer. * * Parameters: * (Object) moreattrs - The attributes to add/modify in object notation. * * Returns: * The Strophe.Builder object. */ attrs: function (moreattrs) { for (var k in moreattrs) this.node.setAttribute(k, moreattrs[k]); return this; }, /** Function: c * Add a child to the current element and make it the new current * element. * * This function moves the current element pointer to the child. If you * need to add another child, it is necessary to use up() to go back * to the parent in the tree. * * Parameters: * (String) name - The name of the child. * (Object) attrs - The attributes of the child in object notation. * * Returns: * The Strophe.Builder object. */ c: function (name, attrs) { var child = this._makeNode(name, attrs); this.node.appendChild(child); this.node = child; return this; }, /** Function: cnode * Add a child to the current element and make it the new current * element. * * This function is the same as c() except that instead of using a * name and an attributes object to create the child it uses an * existing DOM element object. * * Parameters: * (XMLElement) elem - A DOM element. * * Returns: * The Strophe.Builder object. */ cnode: function (elem) { this.node.appendChild(elem); this.node = elem; return this; }, /** Function: t * Add a child text element. * * This *does not* make the child the new current element since there * are no children of text elements. * * Parameters: * (String) text - The text data to append to the current element. * * Returns: * The Strophe.Builder object. */ t: function (text) { var child = Strophe.xmlTextNode(text); this.node.appendChild(child); return this; }, /** PrivateFunction: _makeNode * _Private_ helper function to create a DOM element. * * Parameters: * (String) name - The name of the new element. * (Object) attrs - The attributes for the new element in object * notation. * * Returns: * A new DOM element. */ _makeNode: function (name, attrs) { var node = Strophe.xmlElement(name); for (var k in attrs) node.setAttribute(k, attrs[k]); return node; } }; /** PrivateClass: Strophe.Handler * _Private_ helper class for managing stanza handlers. * * A Strophe.Handler encapsulates a user provided callback function to be * executed when matching stanzas are received by the connection. * Handlers can be either one-off or persistant depending on their * return value. Returning true will cause a Handler to remain active, and * returning false will remove the Handler. * * Users will not use Strophe.Handler objects directly, but instead they * will use Strophe.Connection.addHandler() and * Strophe.Connection.deleteHandler(). */ /** PrivateConstructor: Strophe.Handler * Create and initialize a new Strophe.Handler. * * Parameters: * (Function) handler - A function to be executed when the handler is run. * (String) ns - The namespace to match. * (String) name - The element name to match. * (String) type - The element type to match. * (String) id - The element id attribute to match. * (String) from - The element from attribute to match. * * Returns: * A new Strophe.Handler object. */ Strophe.Handler = function (handler, ns, name, type, id, from) { this.handler = handler; this.ns = ns; this.name = name; this.type = type; this.id = id; this.from = from; // whether the handler is a user handler or a system handler this.user = true; }; Strophe.Handler.prototype = { /** PrivateFunction: isMatch * Tests if a stanza matches the Strophe.Handler. * * Parameters: * (XMLElement) elem - The XML element to test. * * Returns: * true if the stanza matches and false otherwise. */ isMatch: function (elem) { var nsMatch, i; nsMatch = false; if (!this.ns) { nsMatch = true; } else { var self = this; Strophe.forEachChild(elem, null, function (elem) { if (elem.getAttribute("xmlns") == self.ns) nsMatch = true; }); nsMatch = nsMatch || elem.getAttribute("xmlns") == this.ns; } if (nsMatch && (!this.name || Strophe.isTagEqual(elem, this.name)) && (!this.type || elem.getAttribute("type") == this.type) && (!this.id || elem.getAttribute("id") == this.id) && (!this.from || elem.getAttribute("from") == this.from)) { return true; } return false; }, /** PrivateFunction: run * Run the callback on a matching stanza. * * Parameters: * (XMLElement) elem - The DOM element that triggered the * Strophe.Handler. * * Returns: * A boolean indicating if the handler should remain active. */ run: function (elem) { var result = null; try { result = this.handler(elem); } catch (e) { if (e.sourceURL) { Strophe.fatal("error: " + this.handler + " " + e.sourceURL + ":" + e.line + " - " + e.name + ": " + e.message); } else if (e.fileName) { if (typeof(console) != "undefined") { console.trace(); console.error(this.handler, " - error - ", e, e.message); } Strophe.fatal("error: " + this.handler + " " + e.fileName + ":" + e.lineNumber + " - " + e.name + ": " + e.message); } else { Strophe.fatal("error: " + this.handler); } throw e; } return result; }, /** PrivateFunction: toString * Get a String representation of the Strophe.Handler object. * * Returns: * A String. */ toString: function () { return "{Handler: " + this.handler + "(" + this.name + "," + this.id + "," + this.ns + ")}"; } }; /** PrivateClass: Strophe.TimedHandler * _Private_ helper class for managing timed handlers. * * A Strophe.TimedHandler encapsulates a user provided callback that * should be called after a certain period of time or at regular * intervals. The return value of the callback determines whether the * Strophe.TimedHandler will continue to fire. * * Users will not use Strophe.TimedHandler objects directly, but instead * they will use Strophe.Connection.addTimedHandler() and * Strophe.Connection.deleteTimedHandler(). */ /** PrivateConstructor: Strophe.TimedHandler * Create and initialize a new Strophe.TimedHandler object. * * Parameters: * (Integer) period - The number of milliseconds to wait before the * handler is called. * (Function) handler - The callback to run when the handler fires. This * function should take no arguments. * * Returns: * A new Strophe.TimedHandler object. */ Strophe.TimedHandler = function (period, handler) { this.period = period; this.handler = handler; this.lastCalled = new Date().getTime(); this.user = true; }; Strophe.TimedHandler.prototype = { /** PrivateFunction: run * Run the callback for the Strophe.TimedHandler. * * Returns: * true if the Strophe.TimedHandler should be called again, and false * otherwise. */ run: function () { this.lastCalled = new Date().getTime(); return this.handler(); }, /** PrivateFunction: reset * Reset the last called time for the Strophe.TimedHandler. */ reset: function () { this.lastCalled = new Date().getTime(); }, /** PrivateFunction: toString * Get a string representation of the Strophe.TimedHandler object. * * Returns: * The string representation. */ toString: function () { return "{TimedHandler: " + this.handler + "(" + this.period +")}"; } }; /** PrivateClass: Strophe.Request * _Private_ helper class that provides a cross implementation abstraction * for a BOSH related XMLHttpRequest. * * The Strophe.Request class is used internally to encapsulate BOSH request * information. It is not meant to be used from user's code. */ /** PrivateConstructor: Strophe.Request * Create and initialize a new Strophe.Request object. * * Parameters: * (String) data - The data to be sent in the request. * (Function) func - The function that will be called when the * XMLHttpRequest readyState changes. * (Integer) rid - The BOSH rid attribute associated with this request. * (Integer) sends - The number of times this same request has been * sent. */ Strophe.Request = function (data, func, rid, sends) { this.id = ++Strophe._requestId; this.data = data; // save original function in case we need to make a new request // from this one. this.origFunc = func; this.func = func; this.rid = rid; this.date = NaN; this.sends = sends || 0; this.abort = false; this.dead = null; this.age = function () { if (!this.date) return 0; var now = new Date(); return (now - this.date) / 1000; }; this.timeDead = function () { if (!this.dead) return 0; var now = new Date(); return (now - this.dead) / 1000; }; this.xhr = this._newXHR(); }; Strophe.Request.prototype = { /** PrivateFunction: getResponse * Get a response from the underlying XMLHttpRequest. * * This function attempts to get a response from the request and checks * for errors. * * Throws: * "parsererror" - A parser error occured. * * Returns: * The DOM element tree of the response. */ getResponse: function () { var node = null; if (this.xhr.responseXML && this.xhr.responseXML.documentElement) { node = this.xhr.responseXML.documentElement; if (node.tagName == "parsererror") { Strophe.error("invalid response received"); Strophe.error("responseText: " + this.xhr.responseText); Strophe.error("responseXML: " + Strophe.serialize(this.xhr.responseXML)); throw "parsererror"; } } else if (this.xhr.responseText) { Strophe.error("invalid response received"); Strophe.error("responseText: " + this.xhr.responseText); Strophe.error("responseXML: " + Strophe.serialize(this.xhr.responseXML)); } return node; }, /** PrivateFunction: _newXHR * _Private_ helper function to create XMLHttpRequests. * * This function creates XMLHttpRequests across all implementations. * * Returns: * A new XMLHttpRequest. */ _newXHR: function () { var xhr = null; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); if (xhr.overrideMimeType) { xhr.overrideMimeType("text/xml"); } } else if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.onreadystatechange = this.func.prependArg(this); return xhr; } };
最新发布
08-08
<think>我们正在讨论Strophe.js库中的Builder、Handler、TimedHandler和Request类。这些类在XMPP通信中扮演着核心角色。下面我将逐一解析它们的功能,并给出优化建议。 ### 1. Builder类 **功能**:用于构建XML节(stanza),提供链式API简化XML生成。 ```javascript Strophe.Builder = function(name, attrs) { this.nodeTree = Strophe.xmlElement(name, attrs); }; Strophe.Builder.prototype = { tree: function() { return this.nodeTree; }, up: function() { /* 返回父节点 */ }, attrs: function(attrs) { /* 设置属性 */ }, c: function(name, attrs) { /* 添加子节点 */ }, t: function(text) { /* 添加文本节点 */ } }; ``` **优化建议**: - **内存优化**:避免在循环中创建临时Builder对象,改用`reset()`方法复用实例 - **转义强**:自动转义XML特殊字符(如`&`、`<`等) - **链式调用检测**:在开发模式下检测未使用的节点(如创建后未添加到父节点) ### 2. Handler类 **功能**:管理XMPP节(stanza)的事件回调,通过`addHandler()`注册。 ```javascript Strophe.Handler = function(handler, ns, name, type, id, from, options) { this.handler = handler; // 回调函数 this.ns = ns; // 命名空间 this.name = name; // 元素名 this.type = type; // 消息类型(如chat) this.id = id; // 节ID this.from = from; // 发送者JID this.options = options; // 其他选项 }; ``` **优化建议**: - **通配符支持**:允许`ns`和`name`使用`*`匹配任意值 - **优先级系统**:添加`priority`字段控制执行顺序 - **生命周期追踪**:添加唯一ID便于调试和注销 ### 3. TimedHandler类 **功能**:继承自Handler,加超时控制(如IQ请求的响应超时)。 ```javascript Strophe.TimedHandler = function(handler, timeout) { Strophe.Handler.apply(this, arguments); this.timeout = setTimeout(() => { this.handler(null); // 超时触发 this.delete(); }, timeout); }; ``` **优化建议**: - **自动重试**:添加`maxRetries`参数支持自动重试 - **超时回调**:分离超时回调和正常回调(如`onTimeout`选项) - **性能监控**:记录处理时间用于性能分析 ### 4. Request类 **功能**:封装XMLHttpRequest,管理XMPP请求生命周期。 ```javascript Strophe.Request = function(elem, func) { this.data = Strophe.serialize(elem); // 序列化XML this.origFunc = func; // 回调函数 this.xmlHttp = new XMLHttpRequest(); // XHR对象 }; ``` **优化建议**: - **请求池**:实现复用机制避免频繁创建XHR对象 - **错误分类**:根据HTTP状态码细化错误处理(如401重认证) - **取消支持**:添加`abort()`方法支持取消未完成请求 ### 综合优化方案 | 类名 | 内存优化 | 功能强 | 错误处理改进 | |---------------|----------------|-------------------------|--------------------| | Builder | 对象池复用 | 自动XML转义 | 非法结构检测 | | Handler | 弱引用回调 | 通配符匹配 | 异常边界处理 | | TimedHandler | 清除定时器 | 重试机制 | 超时错误码标准化 | | Request | 连接复用 | 请求优先级 | 网络错误分类 | ### 示例:Builder优化实现 ```javascript Strophe.Builder.prototype.text = function(text) { // 自动转义XML特殊字符 const escaped = text.replace(/[<>&]/g, c => ({ '<': '<', '>': '>', '&': '&' }[c])); this.nodeTree.appendChild(Strophe.xmlTextNode(escaped)); return this; }; ``` §§相关问题§§ 1. 如何在Strophe中实现自定义的IQ请求超时处理? 2. Strophe的Builder如何避免XSS攻击? 3. 如何优化Strophe在高频消息场景下的性能? 4. Strophe是否支持WebSocket传输?如何配置? 5. 在Strophe中如何处理XMPP节(stanza)的解析错误?</think>### Strophe.js核心类功能解析与优化建议 #### 1. Builder类(XML构建器) **功能**: - 提供链式API创建XMPP节(stanza) - 自动处理XML命名空间和属性 - 支持嵌套元素和文本内容 ```javascript const msg = new Strophe.Builder("message", {to: "user@domain"}) .c("body").t("Hello world").up() .c("active", {xmlns: "http://jabber.org/protocol/chatstates"}); ``` **优化建议**: - **内存优化**:实现节点复用池,减少DOM操作开销 - **转义强**:自动处理XML特殊字符(如`<`→`<`) - **链式校验**:开发模式下验证节点结构有效性 - **类型推导**:添加TS类型定义强开发体验 #### 2. Handler类(节处理器) **功能**: - 通过`addHandler()`注册消息监听器 - 基于元素名/类型/命名空间过滤节 - 支持多条件组合匹配 ```javascript connection.addHandler( handleMessage, null, // 命名空间 "message", // 元素名 "chat", // 消息类型 null, // ID null, // 发送者 {matchBare: true} ); ``` **优化建议**: - **通配符支持**:允许`*`匹配任意元素/命名空间 - **优先级系统**:添加权重值控制处理器执行顺序 - **调试强**:添加唯一ID和注册堆栈跟踪 - **批量移除**:实现`removeHandlersByNamespace()`等方法 #### 3. TimedHandler类(超时处理器) **功能**: - 继承自Handler,添加超时控制 - 用于IQ请求等需要响应超时的场景 - 自动清理超时处理器 ```javascript const iqHandler = connection.addTimedHandler(5000, () => { console.error("IQ response timeout"); }); ``` **优化建议**: - **自动重试**:添加`maxRetries`参数支持重试机制 - **超时分级**:区分网络超时和服务端超时 - **性能监控**:记录平均响应时间等指标 - **取消传播**:实现`onCancel`回调支持链式中断 #### 4. Request类(请求管理) **功能**: - 封装XMLHttpRequest生命周期 - 管理请求ID与响应映射 - 处理重试逻辑和超时 ```javascript Strophe.Request = function(elem, func) { this.data = Strophe.serialize(elem); this.origFunc = func; // 回调函数 this.xmlHttp = new XMLHttpRequest(); }; ``` **优化建议**: - **连接复用**:实现HTTP/2连接池 - **请求优先级**:添加高/中/低优先级队列 - **智能重试**:基于网络状态动态调整超时 - **压缩支持**:添加`Accept-Encoding: gzip`处理 ### 综合优化方案 | 优化方向 | Builder | Handler | TimedHandler | Request | |----------------|-----------------|----------------|----------------|---------------| | **性能** | 节点复用池 | 通配符匹配 | 批量处理 | 连接复用 | | **稳定性** | 自动转义 | 异常边界处理 | 取消传播 | 智能重试 | | **可维护性** | TS类型定义 | 注册追踪 | 状态机实现 | 事件发射器 | | **扩展性** | 插件系统 | 优先级队列 | 自定义超时策略 | 压缩支持 | ### 示例:优化后的Handler注册 ```javascript // 添加命名空间处理器(优化后) connection.addNamespaceHandler( "urn:xmpp:receipts", // 命名空间 (stanza) => { // 处理函数 console.log("Received delivery receipt", stanza); }, { priority: 10 } // 新优先级 ); // 批量移除处理器 connection.removeHandlersByNamespace("urn:xmpp:receipts"); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值