Results 1 to 7 of 7

Thread: Itemreader

  1. #1
    Join Date
    May 2008
    Posts
    19

    Default Itemreader

    i have this exception, can you help me :

    org.springframework.batch.item.ReaderNotOpenExcept ion: Reader must be open before it can be read.


    my dao classe where i use my itemreader

    Code:
    public class FileADCDao extends JdbcDaoSupport implements IFileADCDao  {
    	
    	private ItemReader itemReader;
    	
    public BeanADC saveAdcFile() {
    		
    		String ligne="";
    		BeanADC beanADC = new BeanADC();
    		
    		try {
    			ligne = itemReader.read().toString();
    			//ligne = "1010;5151;51515;5515";
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		
    		beanADC = repartir(ligne);
    		
    		return(beanADC);
    	}

  2. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    Some ItemReaders like the FlatFileItemReader must be opened before they can be accessed. This is typically handled in the Step where the ItemReader is used. Can you post your configuration and explain what you are trying to do in the Job?
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    That's a very odd setup for an ItemReader. It looks like you have a dao that is 'saving' something, by reading from a file?

    Thomas is correct in that you need to register the reader with the Step (the reference documentation covers how to do this in detail), but it still seems like a bit of an odd setup to me.

  4. #4
    Join Date
    May 2008
    Posts
    19

    Default

    the role of the job is to take each line of a file to execute a query, therefore, whenever I have to take the line that serves as a parameter for the motion and finally take the result of this request to insert it into another table


    tank you for your help

  5. #5
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Shouldn't the line in the file then be the 'item' that the ItemWriter is 'writing' then?

  6. #6
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    Sounds to me that you want to provide some item transformation as part of either the reader or writer. Look at 3.10. Item Transforming for more on how to implement this.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  7. #7
    Join Date
    May 2008
    Posts
    19

    Default

    Quote Originally Posted by lucasward View Post
    Shouldn't the line in the file then be the 'item' that the ItemWriter is 'writing' then?


    no,
    the lines are used just as parameters of requetes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •