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