Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Item Reader in Java ee 7 Batch not working with resultset

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to create Item Reader, Item Processor and Item Writer in Java EE 7 batch in Weblogic 12.2.2. My Item Reader should fetch the data from the database and Processor should consume the data.

For this, i have defined PreparedStatement, ResultSet as a instance variable in Reader. In Open method inside reader, i am fetching the data from database and setting the resultset. In readItem method, i am trying to do resultset.next but there i am getting exception that Resultset is already closed.

Upon debugging, i found that Resultset as well as Prepared Statement both are closed. Because of this i am not able to access the resultset in readItem() method.

Please help, why Prepared Statement and Resultset is getting closed automatically.

Regards,
Sunil
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some code can help. How you setup the PreparedStatement and ResultSet.
 
xsunil kumar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Connection , Prepared Statement and Result set i have defined as instance variable. And in open method, i am preparing statement and querying the database. This will set the value of resultset (instance Variable).

Now in readItem i am trying to read the resultset and getting "Resultset is closed" exception.

Now able to understand, Why resultset in getting closed.

-Sunil
 
Rancher
Posts: 4625
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have closed either the statement or the connection then the result set will be closed.
 
Men call me Jim. Women look past me to this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic