In my app, ResultSet is getting closed by following call. None of my code is suppose to do this. Once ResultSet get close, I can't scroll down on page to see more results. (P.S - initially my page only renders 25 records out of 1500 odd records)
Am I missing setting some property while defining datasource.
Env is based on Db2 + WAS
Driver Name - IBM Data Server Driver for JDBC and SQLJ and Version - 4.8.86
Showing code of using resultSet would be too complicate for me. I have an application build using f/w. This issue only coming up when we deploy this app on WAS and use DB2 as backend.
I have isolate the stack trace ( which I have printed earlier), which is closing the result set.
We are creating PreparedStatement using stmt = mjdbcConnection.prepareStatement(str); where mjdbcConnection is of type "com.ibm.db2.jcc.am.bf" , and setting setMaxRows(0) on it.
After query executed, I am calling clearParameters() on this statement.
Once this all been done, I see IBM code (stack pasted earlier) comes into picture and closing the RS. I have tried setting "autocommit = false" as custom property for my datasouce defined in WAS , but that also doesn't seems to be solving the issue.
Does anything looks suspicious.
Any inputs will be highly appreciated.
Totally agree. But looking at stack trace, would it be possible to guess why that might be happening. I don't see a reason why cleanupTransactions or rollback should get invoke at very first place.
In my WAS server, I have defined a datasource with jndi name "jndi/db2ds" . I have bound this custom method with a Button on my page. When I click on Button, this code executes . Once the execution of this method finishes, I see the below printed stack trace ( totally from IBM stack) executes and tries to cleanup/rollback , during with , its closing the ResultSet rs2.
Any thoughts what's going on here. Please let me know if you need any further information.
There is not much information that I can gather from the code you have given.
Even though I feel
1) You should not keep the resultset open across two calls. Better if you fetch first 25 rows and then next one when "button" is clicked.
2) Not sure if you are using JSP or something else and how your JDBC code is being called. This becomes important as you have mentioned that you "rs" declared as instance level variable.
Can you try putting down pseudo code which might give more insight to this issue?
Firstly , thanks for looking into the matter. Let me try to describe my requirement.
I have a jsp page having a button. On the click action of this button, I need to fetch only 25 rows at a time.
Step a) User click on the button first time. In my custom code which gets call on button click event, I look a datasource and create a new connection, followed by creating a PreparedStatement. Once done, I execute a query and build a Result Set. From this ResultSet, I fetched the initial 25 records only.
Step b) Now when user click the button second time, I want to fetch the next 25 records ( i.e from 26-50 rows) from the previously build ResultSet.
The problem I am facing is, between the two click events of button ( which happens in two different request), cleanup / rollback code from IBM is getting executed ( Please see the stack trace pasted in initial post). This ends up into closing the RS.
Now when we try to perform Step b), as RS has already been closed, hence not able to fetch the next 25 records.
I hope, I've made myself clear. Please let me know if you need any further inputs. Lets not worry about "rs" declared as instance level variable. That was just a typo.
Where are you storing the Resultset on server side ? When user is going to click the button second time, new request is initiated to the server. Are you holding up this resultset somewhere in the HTTPSession for that user?
I have a backing bean at session scope. I have storing my ResultSet in it. My requirement is that which each request , I only fetch 25 set of records from ResultSet, but immaturely closing of RS in WAS environment is stopping me from achieving my requirement.
I love a good mentalist. And so does this tiny ad: