Announcement Announcement Module
Collapse
No announcement yet.
Why Spring Batch doesn't support Informix database. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why Spring Batch doesn't support Informix database.

    Hi All,

    I got the following error while trying to run the football Job sample with Informix Dynamic Server 10.0.

    20:20:32,078 ERROR main CommandLineJobRunner:208 - Job Terminated in error:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobLauncher' defined in class path resource [simple-job-launcher-context.xml]: Cannot resolve reference to bean 'jobRepository' while setting bean property 'jobRepository'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobRepository' defined in class path resource [simple-job-launcher-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: DatabaseType not found for product name: [Informix Dynamic Server]
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:104)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1245)
    .


    I found the this class in api org.springframework.batch.support.DatabaseType
    Enum representing a database type, such as DB2 or oracle. The type also contains a product name, which is expected to the same as the product name provided by the database driver's metadata.

    I am looking for help, How to use the Informix database.
    a) One option is Add the Inormix database in the DatabaseType and complie the bacth code.
    b) Is there any other option?

    Thanks

  • #2
    The reason we detect the database is that many different database types have different 'incrementer' support. If you look at the DataFieldMaxValueIncrementer interface heirarchy, you can see all of the different implementation types. If one of those works for Informix, then you can set the database type manually on the JobRepositoryFactoryBean (we should probably add this to the XSD as well) For example, if you find that the DB2 incrementer works for Informix, then you just set the databaseType property to 'DB2'. If however, none of the available implementations works for you, then you will need to write you own incrementer, and an incrementer factory, which can be wired into the JobRepositoryFactoryBean as well.

    Comment


    • #3
      Spring Batch support to Informix Dynamic Server (IDS) database

      Thanks for quick reply.

      Since I am using Informix Dynamic Server(IDS) database for my Spring Batch application.

      Meta Data Table definition - IDS supports auto incremented data types called SERIAL and SERIAL8. It also have INTEGER data type and support sequence.

      So I have two options for meta data definition
      1) INTEGER data type for meta data ID column in all the tables and a SEQUENCE for corresponding table.
      If I use the INTEGER data type for meta data ID column in all the tables then I need to implement the following class
      a) IDSDaraFieldMaxValueIncrementerFactory implement DataFieldMaxValueIncrementerFactory ( to pass JobRepository)
      b) IDSMaxValueIncrementer extends AbstractColumnMaxValueIncrementer (if not using Sequence for next ID)
      c) IDSSequenceMaxValueIncrementer extends AbstractSequenceMaxValueIncrementer (if using Sequence for next ID)

      2) Use SERIAL data type for all ID column in the meta data tables
      If I use SERIAL data type for all ID column in the meta data table then Can I use a dummy FieldMaxValueIncrementerFactory
      a) IDSDummyDaraFieldMaxValueIncrementerFactory implement DataFieldMaxValueIncrementerFactory ( to pass JobRepository)
      b) IDSDummyMaxValueIncrementer extends AbstractColumnMaxValueIncrementer (if not using Sequence for next ID)
      This dummy implementation will always return a null as next value. So when in insert will be called it will pass null and IDS will generate the actual ID value.

      Questions-
      A) Is my understanding correct? If not please correct me.

      B) If yes which one is better option? If no then how?

      C) To use Spring Batch with Informix do I need any other interface to implement ( like LobHandler)?

      Thanks

      Comment


      • #4
        First of all, you can't implement an incrementer that returns null. We use the incrementers to set the ids on all domain objects. So, you would need to implement an actual one. If I were you, I would double check, just to make sure no existing incrementers will work. If so, you can just use that as your database type. If not, then you will need to create your own incrementer and factory, as I described previously. There really isn't any other alternative.

        That being said, if you do find that you need to write any code, perhaps you can create a jira, so that it might be added to the framework, preventing future users that need informix support from having to take the same steps.

        Comment


        • #5
          Hi,

          I've found an easy workaround to this problem, using spring batch 1.1.4.

          First of all, the database type should be set to "oracle". These forces that all the id retrieval queries are issued thorugh sequences. Something like this:

          select <sequenceName>.nextval from dual.

          The sintaxis for sequences in oracle and informix is quite similar (almost the same). The only problem, is the missing dual table.

          Just create a dummy "dual" table, with one column and one row. These way, the incrementer for oracle should work in an informix database (I'm currently using IDS 11.5). So far, i haven't found any issue.

          Just one more thing. If you are using Hibernate entities, make sure that the generator strategy (if any) is set to sequence, so that you can use the sequence for your entities.

          Hope it works for you....

          Comment

          Working...
          X