cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Heussen <heus...@asspaxx.de>
Subject Re: [ESQL-Bug???] sql exception: invalid cursor state
Date Thu, 23 Sep 2004 09:32:32 GMT
Torsten Curdt schrieb:
>> I'm really no Java guru but maybe I've found a bug in the esql 
>> logicsheet?
> 
> 
> I doubt this is a bug :-)

If not please tell me what I'm doing wrong. The same xsp page running 
under Cocoon 2.0.4 (Tomcat4) with SDK 1.3.1 does not run under Cocoon 
2.1.5.1 (Tomcat5/Jetty) with SDK 1.4.2. I'm just looking on it from a 
users point of view. What changes must be done to my xsp page? This is 
the esql part of my xsp page:

<esql:connection>
   <esql:pool><xsp-session:get-attribute name="server"/>wktkl</esql:pool>
   <esql:execute-query>
     <esql:query>SELECT DISTINCT HSNName FROM TabKFZ</esql:query>
     <esql:results>
       <xforms:select1 ref="FahrzeugsucheHersteller" 
appearance="minimal" tabindex="1" class="FahrzeugsucheHersteller" 
risk="112" server="*" client="*">
         <xforms:choices>
           <esql:row-results>
             <xforms:item>
             <xforms:label><esql:get-string 
column="HSNName"/></xforms:label>
             </xforms:item>
           </esql:row-results>
         </xforms:choices>
       </xforms:select1>
     </esql:results>
     <esql:no-results/>
     <esql:error-results/>
   </esql:execute-query>
</esql:connection>

Remember, only the DISTINCT and GROUP BY sql statements throw the

CascadingRuntimeException: Error getting ascii data for column HSNName 
at 
org.apache.cocoon.components.language.markup.xsp.EsqlHelper.getAscii(EsqlHelper.java:270)


> 
>> The Java class gives the correct result but the esql breaks with the 
>> exception see below.
> 
> 
> Two fundamental differences though.
> Esql uses prepared statements and
> a scrollable ResultSet by default.
> 
> See JdbcEsqlQuery.java for more details.
> 
>> If I use the esql:max-rows element within my xsp page (see comment 
>> above) and gives it a value beneath the expected maximum rows I get no 
>> exception. If I set esql:max-rows to a value above the maximum rows of 
>> the sql result, the same exception is thrown.
>>
>> Can somebody comment this behavior?
> 
> 
> I personally assume this is because
> of the ResultSet type. Instead of the
> default "jdbc" try using e.g. "pervasive"
> instead (uses only a simple ResultSet) and
> please report back.

I'm sorry. Can you explain this for a poor cocoon user ;-)

> 
> For further test: it helps to have a look at
> the generated java code.

I've added the generated java code at the end of this mail. Hope I have 
extracted all necessary parts.

> 
> cheers
> -- 
> Torsten
> 
> 
> 





     if (_esql_connection != null) {
     	_esql_connections.push(_esql_connection);
     }
     try {
     	try {
     		_esql_connection = new Cocoon2EsqlConnection( 
(DataSourceComponent) 
_esql_get_selector().select(String.valueOf(""+(XSPSessionHelper.getSessionAttribute(session,String.valueOf("server"),null))+

"wktkl")) );
     		setupLogger(_esql_connection);
     	} catch (Exception _esql_exception_N10102) {
     		getLogger().error("Could not get the 
datasource",_esql_exception_N10102);
     		throw new RuntimeException("Could not get the datasource 
"+_esql_exception_N10102);
     	}
     	try {
     		if ("false".equalsIgnoreCase(String.valueOf(""))) {
     			if (_esql_connection.getAutoCommit()) {
     				_esql_connection.setAutoCommit(false);
     			}
     		} else {
     			if (!_esql_connection.getAutoCommit()) {
     				_esql_connection.setAutoCommit(true);
     			}
     		}
     	} catch (Exception _esql_exception_N10102) {
     		// do NOT: throw new RuntimeException("Error setting connection
     		// autocommit");
     	}
     	this.characters("\n\t\t\t\t\t\t\t");
     	this.characters("\n\t\t\t\t\t\t\t");
     	
     	if (_esql_query != null) {
     		_esql_queries.push(_esql_query);
     	}
     	_esql_query = 
_esql_connection.createQuery(String.valueOf(""),String.valueOf(""+ 
"SELECT DISTINCT HSNName FROM TabKFZ"));
     	
     	try {
     		_esql_query.prepareStatement();
     		_esql_query.execute();
     		if (getLogger().isDebugEnabled()) {
     			getLogger().debug("esql query: " + _esql_query.getQueryString());
     		}
     		do {
     			if (_esql_query.hasResultSet()) {
     				_esql_query.getResultRows();
     				if (_esql_query.nextRow()) {
     					switch (_esql_query.getQueryResultsCount()) {
     						case 1:
     						default:this.characters("\n\t\t\t\t\t\t\t\t\t");
     						xspAttr.addAttribute(
     								"",
									"ref",
									"ref",
									"CDATA",
									"FahrzeugsucheHersteller"
							);
     						this.contentHandler.startElement(
     								"http://www.w3.org/2002/xforms/cr",
									"select1",
									"xforms:select1",
									xspAttr
							);
     						xspAttr.clear();
     						this.characters("\n\t\t\t\t\t\t\t\t\t\t");
     						XSPObjectHelper.xspExpr(contentHandler, 
FormValidatorHelper.getParamResult(objectModel,"FahrzeugsucheHersteller").ge(ValidatorActionResult.ERROR));
     						this.characters("\n\t\t\t\t\t\t\t\t\t\t");
     						this.contentHandler.startElement(
     								"http://www.w3.org/2002/xforms/cr",
									"label",
									"xforms:label",
									xspAttr
							);
     						xspAttr.clear();
     						this.characters("Fahrzeug-Hersteller");
     						this.contentHandler.endElement(
     								"http://www.w3.org/2002/xforms/cr",
									"label",
									"xforms:label"
							);
     						this.characters("\n\t\t\t\t\t\t\t\t\t\t");
     						this.contentHandler.startElement(
     								"http://www.w3.org/2002/xforms/cr",
									"choices",
									"xforms:choices",
									xspAttr
							);
     						xspAttr.clear();
     						this.characters("\n\t\t\t\t\t\t\t\t\t\t\t");
     						do {
     							this.characters("\n\t\t\t\t\t\t\t\t\t\t\t\t");
     							this.contentHandler.startElement(
     									"http://www.w3.org/2002/xforms/cr",
										"item",
										"xforms:item",
										xspAttr
								);
     							xspAttr.clear();
     							this.characters("\n\t\t\t\t\t\t\t\t\t\t\t\t\t");
     							this.contentHandler.startElement(
     									"http://www.w3.org/2002/xforms/cr",
										"label",
										"xforms:label",
										xspAttr
								);
     							xspAttr.clear();
     							XSPObjectHelper.xspExpr(contentHandler,
     									EsqlHelper.getAscii(_esql_query.getResultSet(),"HSNName","")
								);
     							this.contentHandler.endElement(
     									"http://www.w3.org/2002/xforms/cr",
										"label",
										"xforms:label"
								);
     							this.characters("\n\t\t\t\t\t\t\t\t\t\t\t\t\t");
     							this.contentHandler.endElement(
     									"http://www.w3.org/2002/xforms/cr",
										"item",
										"xforms:item"
								);
     							this.characters("\n\t\t\t\t\t\t\t\t\t\t\t");
     							//checking out early?
     							if (_esql_query.getMaxRows() != -1 && 
_esql_query.getCurrentRow() - _esql_query.getSkipRows() == 
_esql_query.getMaxRows()) {
     								_esql_query.setKeepGoing( false );
     							} else {	//if not, advance normally
     								_esql_query.setKeepGoing( _esql_query.nextRow() );
     							}
     						}
     						while ( _esql_query.keepGoing() );
     						if (_esql_query.getSkipRows() > 0 ) {
     						}
     						if (_esql_query.nextRow()) {
     						}
     						this.characters("\n\t\t\t\t\t\t\t\t\t\t");
     						this.contentHandler.endElement(
     								"http://www.w3.org/2002/xforms/cr",
									"choices",
									"xforms:choices"
							);
     						this.characters("\n\t\t\t\t\t\t\t\t\t");
     						this.contentHandler.endElement(
     								"http://www.w3.org/2002/xforms/cr",
									"select1",
									"xforms:select1"
							);
     						this.characters("\n\t\t\t\t\t\t\t\t");
     						break;
     					}
     				} else {
     					switch (_esql_query.getUpdateResultsCount()) {
     						case 1:
     						default:
     						this.contentHandler.startElement(
     								"",
									"no-results",
									"no-results",
									xspAttr
							);
     						xspAttr.clear();
     						this.contentHandler.endElement(
     								"",
									"no-results",
									"no-results"
							);
     						xspAttr.addAttribute(
     								"",
									"code",
									"code",
									"CDATA",
									"500"
							);
     						this.contentHandler.startElement(
     								"http://schema.rheinland.net/matrix/matrix.htm",
									"internal-error",
									"matrix:internal-error",
									xspAttr
							);
     						xspAttr.clear();
     						
     						this.characters("SELECT DISTINCT HSNName FROM TabKFZ");
     						this.contentHandler.endElement(
     								"http://schema.rheinland.net/matrix/matrix.htm",
									"internal-error",
									"matrix:internal-error"
							);
     						break;
     					}
     				}
     				_esql_query.getResultSet().close();
     			} else {
     				if (_esql_query.getUpdateCount() > 0) {
     					switch (_esql_query.getUpdateResultsCount()) {
     					}
     				} else {
     					switch (_esql_query.getUpdateResultsCount()) {
     					}
     				}
     			}
     		}
     		while(_esql_connection.getMultipleResults() && 
_esql_query.getMoreResults());
    			_esql_query.getPreparedStatement().close();
    		} catch (SQLException _esql_exception_N1010C) {
    			try {
    				_esql_exception = _esql_exception_N1010C;
    				_esql_exception_writer = new StringWriter();
    				_esql_exception.printStackTrace(new 
PrintWriter(_esql_exception_writer));
    				if (!_esql_connection.getAutoCommit()) {
    					_esql_connection.rollback();
    				}
    			} catch (Exception _esql_exception_N1010C_2) {}
    		} finally {
    			_esql_query.cleanUp();
    		}
    		if (_esql_queries.empty()) {
    			_esql_query = null;
    		} else {
    			_esql_query = (AbstractEsqlQuery)_esql_queries.pop();
    		}
    		this.characters("\n\t\t\t\t\t\t");
    	} catch (SQLException _esql_exception_N10102) {
    		getLogger().error("",_esql_exception_N10102);
    	} finally {
    		try {
    			if(!_esql_connection.getAutoCommit()) {
    				_esql_connection.commit();
    			}
    			_esql_connection.close();
    			if (_esql_connections.empty()) {
    				_esql_connection = null;
    			} else {
    				_esql_connection = (Cocoon2EsqlConnection)_esql_connections.pop();
    			}
    		} catch (Exception _esql_exception_N10102) {}
    	}

Mime
View raw message