Announcement Announcement Module
Collapse
No announcement yet.
error when trying to switch from in-memory repository to persistent repository Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error when trying to switch from in-memory repository to persistent repository

    Hi community,

    I got the following exception when starting my batch (I use PostgresSQL with sequence management of ID)


    Code:
    Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is org.postgresql.util.PSQLException: ERREUR: la relation  batch_job_instance  n'existe pas
      Position*: 39
    	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
    	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
    	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714)
    	at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:204)
    	at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:209)
    	at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.getJobInstance(JdbcJobInstanceDao.java:223)
    	at org.springframework.batch.core.repository.support.SimpleJobRepository.getLastJobExecution(SimpleJobRepository.java:253)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    	at $Proxy13.getLastJobExecution(Unknown Source)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:94)
    	at com.ubik.newapp.batch.BatchVente.main(BatchVente.java:24)
    Caused by: org.postgresql.util.PSQLException: ERREUR: la relation  batch_job_instance  n'existe pas
      Position*: 39
    	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
    	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:644)
    	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
    	... 21 more
    Here is my configuration :

    Code:
    	<bean id="dataSource" destroy-method="close"
    		class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="driverClassName" value="org.postgresql.Driver" />
    		<property name="url" value="jdbc:postgresql://127.0.0.1:5432/ubik" />
    		<property name="username" value="postgres" />
    		<property name="password" value="postgres" />
    	</bean>
    
    	<bean id="jobLauncher"
    		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    		<property name="jobRepository" ref="jobRepository" />
    	</bean>
    
    <!-- 	<bean id="jobRepository" -->
    <!-- 		class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean" /> -->
    
    
    
    	<batch:job-repository id="jobRepository" data-source="dataSource"
    		transaction-manager="transactionManager" isolation-level-for-create="DEFAULT"
    		table-prefix="BATCH_" max-varchar-length="1000" />
    Thanx all

  • #2
    My French isn't that good but judging from the stacktrace there are no tables in your database. Maybe creation isn't going well... You could try creating the tables yourself.

    Comment


    • #3
      yes, it works fine when i directly run the SQL script on Postgres.

      Thank you

      Comment

      Working...
      X