1

In Spring Batch , when are meta data tables dropped?

I see drop sql file at - /org/springframework/batch/core/... but not sure if its some trigger from program ( Batch Job itself ) that drops these tables or these tables need to be dropped manually or does it have anything to do with batch admin?

Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
  • Thanks, actually I have another [SO question](http://stackoverflow.com/questions/39072510/spring-batch-reader-for-distributed-db2-database) so I am planning to create tables manually to address point # 1. So I was wondering if tables gets dropped automatically or not since one time creation is OK but I will not be able to repeat it. – Sabir Khan Aug 22 '16 at 08:18
  • You can put your comment as answer so I can accept. – Sabir Khan Sep 02 '16 at 12:34

2 Answers2

1

I suppose they are never dropped automatically but a manual action is always required (from SB admin) or from your application (as part of your application service layer)

Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
0

The meta data tables are not created automatically nor are they dropped automatically.

You need to do it yourself once. (This can be automated if necessary but need not be.)

Spring boot does provide a facility that automatically will create the tables needed, but that is not part of the native Spring Batch functionality.

Wiszh
  • 511
  • 5
  • 20
  • when I start spring batch app, I see this in logs `Executing SQL script from class path resource [org/springframework/batch/core/schema-db2.sql]`. This sql file has `CREATE TABLE` statements. Eventually, tables are not created because provided SQL is not compatible with my db2 installation but create is attempted automatically. How can I stop this automatic sql file execution? – Sabir Khan Aug 30 '16 at 06:41
  • SQL script execution fails in error but dumps this in logs, `INFO - 2016-08-30 11:13:56.606; org.springframework.jdbc.datasource.init.ScriptUtils; Executed SQL script from class path resource [org/springframework/batch/core/schema-db2.sql] in 3609 ms.` so if I go by logs, spring batch attempts to create tables automatically even though it fails to do so due to sql not being compatible with my db2 installtion.I don't see `schema-drop-db2` in logs so agree with drop part but not create part. – Sabir Khan Aug 30 '16 at 06:47
  • Please [see this](http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-spring-batch-database). By default table creations are enabled, I need to turn it off by specifying property. – Sabir Khan Sep 02 '16 at 12:31
  • 1
    This is a spring boot functionality not a native part of Spring Batch – Wiszh Sep 12 '16 at 15:48
  • ok, It seems I got confused between plain spring batch and spring batch with spring boot. Thanks for clarifying. I think, you should edit your answer to add this point. – Sabir Khan Sep 15 '16 at 09:51