Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SQLTransform cause JDBC error

    Versions: SmartGWT EE 2.5, GWT 2.5

    Code TestTable.ds.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <DataSource
    	tableName="TestTable"
    	serverType="sql"
    	ID="TestTable">
    	<fields>
    		<field name="ID" type="integer" primaryKey="true" required="false"/>
    		<field name="OrderCol" type="integer" required="false"/>
    		<field name="SomeText" type="text" required="false"/>
    	</fields>
    	<operationBindings>
    		<operationBinding operationType="fetch">
    			<orderClause>OrderCol</orderClause>
    		</operationBinding>
    		<operationBinding operationType="add">
    			<tableClause>TestTable</tableClause>
    			<valuesClause>(OrderCol, SomeText) VALUES (NULL, $values.SomeText)</valuesClause>
    		</operationBinding>
    		<operationBinding operationType="custom" operationId="swapOrder">
    			<customSQL>call swapOrder($httpParameters.idA, $httpParameters.idB)</customSQL>
    		</operationBinding>
    	</operationBindings>
    </DataSource>
    Sending request:
    Code:
    		buttonUp.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				Record afterRecord = list.getSelectedRecord();
    				if(afterRecord != null) {
    					final int index = list.getRecordIndex(afterRecord);
    					if(index > 0) {
    						Record beforeRecord = list.getRecord(index - 1);
    						int afterRecordID = afterRecord.getAttributeAsInt("ID");
    						int beforeRecordID = beforeRecord.getAttributeAsInt("ID");
    						DataSource ds = DataSource.getDataSource("TestTable");
    						Record swapRecord = new Record();
    						DSRequest request = new DSRequest();
    						Map<String,String> params = new HashMap<String, String>();
    						params.put("idA", String.valueOf(afterRecordID));
    						params.put("idB", String.valueOf(beforeRecordID));
    						request.setParams(params);
    						ds.performCustomOperation("swapOrder", swapRecord, new DSCallback() {
    							
    							@Override
    							public void execute(DSResponse response, Object rawData, DSRequest request) {
    								list.refreshRow(index);
    								list.refreshRow(index - 1);
    							}
    						}, request);
    					}
    				}
    			}
    			
    		});
    Logs:
    Code:
    === 2011-09-16 12:48:39,462 [0-64] INFO  RequestContext - URL: '/buildingmanagement/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1': Safari with Accept-Encoding header
    === 2011-09-16 12:48:39,464 [0-64] DEBUG XML - Parsed XML from (in memory stream): 1ms
    === 2011-09-16 12:48:39,465 [0-64] DEBUG RPCManager - Processing 1 requests.
    === 2011-09-16 12:48:39,466 [0-64] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        values:{
            __gwt_ObjectId:305
        },
        operationConfig:{
            dataSource:"TestTable",
            operationType:"custom"
        },
        appID:"builtinApplication",
        operation:"swapOrder",
        oldValues:{
            __gwt_ObjectId:305
        },
        criteria:{
        }
    }
    === 2011-09-16 12:48:39,466 [0-64] INFO  IDACall - Performing 1 operation(s)
    === 2011-09-16 12:48:39,466 [0-64] DEBUG AppBase - [builtinApplication.swapOrder] No userTypes defined, allowing anyone access to all operations for this application
    === 2011-09-16 12:48:39,466 [0-64] DEBUG AppBase - [builtinApplication.swapOrder] No public zero-argument method named '_swapOrder' found, performing generic datasource operation
    === 2011-09-16 12:48:39,466 [0-64] INFO  SQLDataSource - [builtinApplication.swapOrder] Performing custom operation with
    	criteria: {}	values: {__gwt_ObjectId:305}
    === 2011-09-16 12:48:39,466 [0-64] INFO  SQLValuesClause - [builtinApplication.swapOrder] Ignored data for non-existent columns: [__gwt_ObjectId]
    === 2011-09-16 12:48:39,466 [0-64] DEBUG SQLValuesClause - [builtinApplication.swapOrder] Sequences: {}
    === 2011-09-16 12:48:39,466 [0-64] INFO  SQLWhereClause - [builtinApplication.swapOrder] empty condition
    === 2011-09-16 12:48:39,472 [0-64] DEBUG PoolableSQLConnectionFactory - [builtinApplication.swapOrder] Returning pooled Connection
    === 2011-09-16 12:48:39,473 [0-64] INFO  SQLDriver - [builtinApplication.swapOrder] Executing SQL query on 'Mysql': call swapOrder('10', '8')
    === 2011-09-16 12:48:39,552 [0-64] DEBUG SQLTransform - [builtinApplication.swapOrder] isBeforeFirst()/isAfterLast() throwing exceptions - attempting workaround
    === 2011-09-16 12:48:39,552 [0-64] WARN  RequestContext - dsRequest.execute() failed: 
    java.lang.NullPointerException
    	at com.mysql.jdbc.ResultSetImpl.getRow(ResultSetImpl.java:5291)
    	at org.apache.commons.dbcp.DelegatingResultSet.getRow(DelegatingResultSet.java:332)
    	at com.isomorphic.sql.SQLTransform.toListOfMapsOrBeans(SQLTransform.java:514)
    	at com.isomorphic.sql.SQLTransform.toListOfMapsOrBeans(SQLTransform.java:425)
    	at com.isomorphic.sql.SQLDriver.getTransformedResults(SQLDriver.java:321)
    	at com.isomorphic.sql.SQLDriver.executeQuery(SQLDriver.java:562)
    	at com.isomorphic.sql.SQLDataSource.executeNativeQuery(SQLDataSource.java:376)
    	at com.isomorphic.sql.SQLDataSource.executeNativeQuery(SQLDataSource.java:371)
    	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1289)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:280)
    	at com.isomorphic.sql.SQLDataSource.executeCustom(SQLDataSource.java:240)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1174)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
    	at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
    	at com.isomorphic.application.AppBase.execute(AppBase.java:491)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1714)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    It's look as SmartGWT try to process response from stored procedure. Is't possible to fix this bug or avoid interaction with SQLTransform when I use stored procedures?
    Last edited by vomifort; 16 Sep 2011, 01:18.

    #2
    It's not a bug in SQLTransform, the crashing line of code is in your JDBC driver. You might try installing a more recent JDBC driver if one is available.

    If that doesn't fix it, you should see if it's possible for you to get a correct result out of your JDBC driver for this stored procedure at all - if it is, please show us code that would work, and perhaps calls could be rearranged to avoid hitting this driver bug.

    Comment


      #3
      Here is a code of procedure:
      Code:
      CREATE DEFINER=`root`@`localhost` PROCEDURE `swapOrder`(IN idA INT UNSIGNED, IN idB INT UNSIGNED)
      BEGIN
      	SET @orderA = (SELECT OrderCol FROM TestTable WHERE ID=idA);
      	SET @orderB = (SELECT OrderCol FROM TestTable WHERE ID=idB);
      	UPDATE TestTable SET OrderCol = @orderB WHERE ID=idA;
      	UPDATE TestTable SET OrderCol = @orderA WHERE ID=idB;
      END
      I'm changing this to update operation but will be glad to see more simple solution.
      Last edited by vomifort; 19 Sep 2011, 00:40.

      Comment

      Working...
      X