Announcement Announcement Module
Collapse
No announcement yet.
Newbie: Help for SQL Server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie: Help for SQL Server

    Hi there,

    I am totally new to Spring Batch, but have worked with Spring in one project.

    Can you pls. help me with, or direct me to information about:

    - Telling Spring Batch Core to use my database on SQL Server.
    - Telling the samples to use my database on SQL Server.
    - Pointing out which configuration/property files I need to run one of the samles from a command line.

    I have successfully downloaded the the core and samples and have tried running one og the samples as a JUnit. But I can't figure out how to switch from the default (?) hsql til Microsoft SQL Server.

    ANY help is appreciated.

    Thanks in advance
    Preben

  • #2
    Unfortunately Spring does not provide an incrementer for MSSQL, which Spring Batch requires. See http://jira.springframework.org/browse/BATCH-328

    Otherwise you can switch samples to using different databases by setting the 'environment' system property (see environment bean in data-source-context.xml).

    Comment


    • #3
      Hi Robert,

      Thanks for the quick response. Working with SQL Server I have found out that the system itself has a method for incrementing ID field.

      If I declare a field on the database as:
      ID INTEGER IDENTITY(0,1)

      then SQL Server will automatically increment the value of that field every time I insert a row in the table.

      Does that bring me closer to working with Spring Batch and SQL Server in conjunction ?

      I'm right now trying to figure out how alter the SQL for the Spring Batch CORE and for the samples. Will post it here, if I get it to run :-)

      /Preben

      Comment


      • #4
        Does that bring me closer to working with Spring Batch and SQL Server in conjunction ?
        I'm afraid not really, you'll still need the DataFieldMaxValueIncrementer that framework expects - I don't know any way around that.

        Comment


        • #5
          Hi Robert,

          Thanks for the response. My problem is, that I ONLY have an SQL Server 2005.

          I can see in the simple-job-launcher-context.xml in the samples project, that the org.springframework.batch.core.repository.support. JobRepositoryFactoryBean is configured with an environment.

          Will it be possible for me to provide it with a DataFieldMaxValueIncrementerFactory, that supports my way of working with Microsoft SQL ? I figure that I could either do it as a parameter in the simple-job-launcher-context.xml or use my own copy of JobRepositoryFactoryBean.

          Would that be a way to proceed ?

          Best regards
          Preben

          Comment


          • #6
            It still goes down to having the incrementer implementation for MSSQL - the DataFieldMaxValueIncrementerFactory and JobRepositoryFactoryBean are just abstraction for simplifying configuration (you don't need to use them). I don't know any good way to bypass having an incrementer.

            Implementing a MssqlDataFieldMaxValueIncrementer might be quite easy as far as I can guess - e.g. take a look at PostgreSQL implementation if sequences apply for MSSQL or Mysql implementation if not. Sooner or later somebody will do it, but frankly the issue has been out there for quite a while unresolved.

            Comment


            • #7
              Created basic MsSQLMaxValueIncrementer

              Thanks for the advice Robert.

              I created a basic MsSQLMaxValueIncrementer as a copy of the HSQL one and got it to work (tested it with the football job).

              To get it to work, I also made local copies of DefaultDataFieldMaxValueIncrementerFactory (adding mssql as an option) and JobRepositoryFactoryBean (pointing to my local DefaultDataFieldMaxValueIncrementerFactory).

              I am sure that you guys can figure out a more sleek way of implementing it.
              If anyone wants to put it into the project, I also have the sql files for creating the tables in mssql for both the core tables and the business tables.
              Core tables:
              Business tables:

              Best regards
              Preben

              Comment


              • #8
                Preben,

                great to hear you made things work with MSSQL. Could you attach the files to the related jira issue http://jira.springframework.org/browse/BATCH-328 (zip is probably most convenient)?

                The incrementer alone would be relevant to Spring Core as well (there's a link in the batch issue to corresponding core issue).

                Thanks
                Robert

                Comment

                Working...
                X