Hi Harsha,

Thank you for pointing out that. Yes, we can keep the method signature as
it is. I have changed the pull request with your suggestion.


Thanks,
Chanaka

On Sun, Feb 15, 2015 at 3:20 PM, Harsha Thirimanna <hars...@wso2.com> wrote:

> ​Hi Chanaka,
>
> Yes , either we have to read the result and fill to some data object
> within this method or use CachedRowSet.
>
> But when we use CachedRowSet impl within the method to wrap the ResultSet,
> we don't need to change the method signature and consumer doesn't need to
> depend on this ​CachedRowSet impl. Instead of that , you can just keep
> return type as ResultSet. WDYT ?
>
>
> *Harsha Thirimanna*
> Senior Software Engineer; WSO2, Inc.; http://wso2.com
> * <http://www.apache.org/>*
> *email: **hars...@wso2.com* <az...@wso2.com>* cell: +94 71 5186770  ,
> +94 *
> *774617784twitter: **http://twitter.com/
> <http://twitter.com/afkham_azeez>*
> *harshathirimannlinked-in: **http:
> <http://lk.linkedin.com/in/afkhamazeez>**//www.linkedin.com/pub/harsha-thirimanna/10/ab8/122
> <http://www.linkedin.com/pub/harsha-thirimanna/10/ab8/122>*
>
> *Lean . Enterprise . Middleware*
>
>
> On Sun, Feb 15, 2015 at 2:55 PM, Chanaka Fernando <chana...@wso2.com>
> wrote:
>
>> Hi All,
>>
>> I have found a fix for the above mentioned issue. We can  use the
>> CachedRowSet[1] implementation to get the result set and manipulate the
>> results with that. I have created the pull request with the fix [2]. This
>> approach will make sure that the connections are properly closed and the
>> data set is available to manipulate. Please review the fix and merge.
>>
>> [1]
>> http://docs.oracle.com/javase/7/docs/api/javax/sql/rowset/CachedRowSet.html
>> [2] https://github.com/wso2/carbon-platform-integration/pull/42
>>
>>
>> Thanks,
>> Chanaka
>>
>> On Sun, Feb 15, 2015 at 1:39 PM, Chanaka Fernando <chana...@wso2.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> I am trying to fix the dbreport integration test case for the ESB 4.9.0
>>> release and came through the below exception from the automation framework.
>>>
>>> java.sql.SQLException: Operation not allowed after ResultSet closed
>>>     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
>>>     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
>>>     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
>>>     at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:768)
>>>     at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7008)
>>>     at
>>> org.wso2.carbon.esb.mediator.test.db.dbreport.DBReportMediatorTestCase.getPrice(DBReportMediatorTestCase.java:209)
>>>     at
>>> org.wso2.carbon.esb.mediator.test.db.dbreport.DBReportMediatorTestCase.DBReportUseMessageContentTestCase(DBReportMediatorTestCase.java:141)
>>>
>>>
>>> When I go through the code of the automation framework, I found out that
>>> the below code segment in the MySqlDatabaseManager class. *This will
>>> close the Statement after executing. But that operation will eventually
>>> closes the result set according to the java documentation[1]*
>>>
>>>     /**
>>>      * @param sql
>>>      * @return
>>>      * @throws java.sql.SQLException
>>>      */
>>>     public ResultSet executeQuery(String sql) throws SQLException {
>>>         ResultSet rs;
>>>         Statement st = null;
>>>         try {
>>>             st = connection.createStatement();
>>>             log.debug(sql);
>>>             rs = st.executeQuery(sql);
>>>         } finally {
>>>             if (st != null) {
>>>                 st.close();
>>>             }
>>>         }
>>>         return rs;
>>>     }
>>>
>>> Due to this reason, we cannot look in to the result set within the
>>> integration test code which is a requirement for this specific test case of
>>> dbreport mediator.
>>>
>>> ResultSet rs = mySqlDatabaseManager.executeQuery("SELECT price from
>>> company WHERE name = 'WSO2'");
>>>
>>>         while (rs.next()) {
>>>             price = Double.toString(rs.getDouble("price"));
>>>         }
>>>
>>>
>>> In the above code, it fails when trying to call the rs.next() since the
>>> result set is already closed.
>>>
>>> WDYT?
>>>
>>>
>>> [1]
>>> http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#executeQuery%28java.lang.String%29
>>>
>>>
>>> Thanks,
>>> Chanaka
>>>
>>> --
>>> --
>>> Chanaka Fernando
>>> Technical Lead
>>> WSO2, Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> mobile: +94 773337238
>>> Blog : http://soatutorials.blogspot.com
>>> LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
>>> Twitter:https://twitter.com/chanakaudaya
>>> Wordpress:http://chanakaudaya.wordpress.com
>>>
>>>
>>>
>>>
>>
>>
>> --
>> --
>> Chanaka Fernando
>> Technical Lead
>> WSO2, Inc.; http://wso2.com
>> lean.enterprise.middleware
>>
>> mobile: +94 773337238
>> Blog : http://soatutorials.blogspot.com
>> LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
>> Twitter:https://twitter.com/chanakaudaya
>> Wordpress:http://chanakaudaya.wordpress.com
>>
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>


-- 
--
Chanaka Fernando
Technical Lead
WSO2, Inc.; http://wso2.com
lean.enterprise.middleware

mobile: +94 773337238
Blog : http://soatutorials.blogspot.com
LinkedIn:http://www.linkedin.com/pub/chanaka-fernando/19/a20/5b0
Twitter:https://twitter.com/chanakaudaya
Wordpress:http://chanakaudaya.wordpress.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to