Announcement Announcement Module
Collapse
No announcement yet.
Itemreader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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?

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


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

          Comment


          • #6
            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.

            Comment


            • #7
              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

              Comment

              Working...
              X