Results 1 to 8 of 8

Thread: Newbie: Help for SQL Server

  1. #1

    Default 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. #2

    Default

    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).

  3. #3

    Default

    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

  4. #4

    Default

    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.

  5. #5

    Default

    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

  6. #6

    Default

    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.

  7. #7

    Default Created basic MsSQLMaxValueIncrementer

    Thanks for the advice Robert.

    I created a basic MsSQLMaxValueIncrementer MsSQLMaxValueIncrementer.java.txt 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 DefaultDataFieldMaxValueIncrementerFactory.java.txt (adding mssql as an option) and JobRepositoryFactoryBean JobRepositoryFactoryBean.java.txt (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: schema-mssql.sql.txt
    Business tables: business-schema-mssql.sql.txt

    Best regards
    Preben

  8. #8

    Default

    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

Posting Permissions

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