Results 1 to 3 of 3

Thread: error when trying to switch from in-memory repository to persistent repository

  1. #1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

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

    Thank you

Posting Permissions

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