Spring Batch
  1. Spring Batch
  2. BATCH-360

Failed to create new StepExecution record in DB2 due to unsupported null value when calling JdbcTemplate.update

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.0.0.m4
    • Fix Version/s: 1.0.0.m5
    • Component/s: Core
    • Labels:
      None

      Description

      When the Job is launched, a StepExecution record is created with Spring JdbcTemplate.update method. Then
      the following exception is thrown:

      Caused by: com.ibm.db2.jcc.b.SqlException: [jcc][10271][10295][3.50.152] Unrecognized JDBC type: 0. ERRORCODE=-4228, SQLSTATE=null
      at com.ibm.db2.jcc.b.wc.a(wc.java:55)
      at com.ibm.db2.jcc.b.wc.a(wc.java:102)
      at com.ibm.db2.jcc.b.cb.i(cb.java:1219)
      at com.ibm.db2.jcc.b.uk.b(uk.java:612)
      at com.ibm.db2.jcc.b.uk.setNull(uk.java:584)
      at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValueInternal(StatementCreatorUtils. java:173)
      at org.springframework.jdbc.core.StatementCreatorUtil s.setParameterValue(StatementCreatorUtils.java:88)
      at org.springframework.jdbc.core.ArgPreparedStatement Setter.setValues(ArgPreparedStatementSetter.java:5 1)
      at org.springframework.jdbc.core.JdbcTemplate$2.doInP reparedStatement(JdbcTemplate.java:771)
      at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:566)

      It seems to be a problem with JdbcTemplate when working with db2 null value.

      There is also a bug report in spring support forum:

      http://forum.springframework.org/showthread.php?p=165078

        Activity

        Hide
        Dave Syer added a comment -

        It would actually help to see more of the stack trace, since the one posted deos not include anything from Spring Batch source code. Can you also specify the version of DB2 (server and client) you are using?

        Show
        Dave Syer added a comment - It would actually help to see more of the stack trace, since the one posted deos not include anything from Spring Batch source code. Can you also specify the version of DB2 (server and client) you are using?
        Hide
        steven added a comment -

        The following is the stack trace before the exception is thrown:

        Thread [pool-1-thread-5] (Suspended (breakpoint at line 623 in JdbcStepDao))
        JdbcStepDao.update(StepInstance) line: 623
        SimpleJobRepository.update(StepInstance) line: 279
        NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
        NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
        DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
        Method.invoke(Object, Object...) line: not available
        AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: 304
        ReflectiveMethodInvocation.invokeJoinpoint() line: 182
        ReflectiveMethodInvocation.proceed() line: 149
        TransactionInterceptor.invoke(MethodInvocation) line: 106
        ReflectiveMethodInvocation.proceed() line: 171
        ExposeInvocationInterceptor.invoke(MethodInvocation) line: 89
        ReflectiveMethodInvocation.proceed() line: 171
        JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 204
        $Proxy35.update(StepInstance) line: not available
        SimpleStepExecutor.updateStatus(StepExecution, BatchStatus) line: 304
        SimpleStepExecutor.execute(StepExecution) line: 275
        SimpleStep(AbstractStep).execute(StepExecution) line: 131
        SimpleJob.execute(JobExecution) line: 82
        SimpleJobLauncher$1.run() line: 85
        ThreadPoolExecutor$Worker.runTask(Runnable) line: not available
        ThreadPoolExecutor$Worker.run() line: not available
        Thread.run() line: not available

        the exception thrown is:

        target UncategorizedSQLException (id=9774)
        cause SqlException (id=9775)
        cause UncategorizedSQLException (id=9774)
        detailMessage "PreparedStatementCallback; uncategorized SQLException for SQL [UPDATE BATCH_STEP_INSTANCE set LAST_STEP_EXECUTION_ID = ? where STEP_INSTANCE_ID = ?]; SQL state [null]; error code [-99999]; [ibm][db2][jcc][10281][10295] Unrecognized JDBC type 0。"
        sql "UPDATE BATCH_STEP_INSTANCE set LAST_STEP_EXECUTION_ID = ? where STEP_INSTANCE_ID = ?"
        stackTrace null

        when the following method is executed:
        class JdbcStepDao {
        public void update(final StepInstance step) {

        Assert.notNull(step, "Step cannot be null.");
        Assert.notNull(step.getId(), "Step Id cannot be null.");

        Object[] parameters = new Object[]

        { step.getLastExecution().getId(), step.getId() }

        ;

        jdbcTemplate.update(getUpdateStepQuery(), parameters);
        }

        the first parameter (step.getLastExecution().getId()) is null which caused the UncategorizedSQLException .

        We are running DB2 9.0 using jcc type 4 driver com.ibm.db2.jcc.DB2Driver.

        Show
        steven added a comment - The following is the stack trace before the exception is thrown: Thread [pool-1-thread-5] (Suspended (breakpoint at line 623 in JdbcStepDao)) JdbcStepDao.update(StepInstance) line: 623 SimpleJobRepository.update(StepInstance) line: 279 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available Method.invoke(Object, Object...) line: not available AopUtils.invokeJoinpointUsingReflection(Object, Method, Object[]) line: 304 ReflectiveMethodInvocation.invokeJoinpoint() line: 182 ReflectiveMethodInvocation.proceed() line: 149 TransactionInterceptor.invoke(MethodInvocation) line: 106 ReflectiveMethodInvocation.proceed() line: 171 ExposeInvocationInterceptor.invoke(MethodInvocation) line: 89 ReflectiveMethodInvocation.proceed() line: 171 JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 204 $Proxy35.update(StepInstance) line: not available SimpleStepExecutor.updateStatus(StepExecution, BatchStatus) line: 304 SimpleStepExecutor.execute(StepExecution) line: 275 SimpleStep(AbstractStep).execute(StepExecution) line: 131 SimpleJob.execute(JobExecution) line: 82 SimpleJobLauncher$1.run() line: 85 ThreadPoolExecutor$Worker.runTask(Runnable) line: not available ThreadPoolExecutor$Worker.run() line: not available Thread.run() line: not available the exception thrown is: target UncategorizedSQLException (id=9774) cause SqlException (id=9775) cause UncategorizedSQLException (id=9774) detailMessage "PreparedStatementCallback; uncategorized SQLException for SQL [UPDATE BATCH_STEP_INSTANCE set LAST_STEP_EXECUTION_ID = ? where STEP_INSTANCE_ID = ?] ; SQL state [null] ; error code [-99999] ; [ibm] [db2] [jcc] [10281] [10295] Unrecognized JDBC type 0。" sql "UPDATE BATCH_STEP_INSTANCE set LAST_STEP_EXECUTION_ID = ? where STEP_INSTANCE_ID = ?" stackTrace null when the following method is executed: class JdbcStepDao { public void update(final StepInstance step) { Assert.notNull(step, "Step cannot be null."); Assert.notNull(step.getId(), "Step Id cannot be null."); Object[] parameters = new Object[] { step.getLastExecution().getId(), step.getId() } ; jdbcTemplate.update(getUpdateStepQuery(), parameters); } the first parameter (step.getLastExecution().getId()) is null which caused the UncategorizedSQLException . We are running DB2 9.0 using jcc type 4 driver com.ibm.db2.jcc.DB2Driver.
        Hide
        Dave Syer added a comment -

        That might be a bug in the step dao. We need to use the explicit types if values can be null. It looks like the last step execution might be null there as well, so I worry that there is something wrong about that.

        Show
        Dave Syer added a comment - That might be a bug in the step dao. We need to use the explicit types if values can be null. It looks like the last step execution might be null there as well, so I worry that there is something wrong about that.
        Hide
        Robert Kasanicky added a comment -

        In current trunk there is no longer a update(StepInstance) method (the column referencing the last execution has been removed from both job_instance and step_instance tables). Steven, can you test whether running with M5-snapshot solves the problem?

        Show
        Robert Kasanicky added a comment - In current trunk there is no longer a update(StepInstance) method (the column referencing the last execution has been removed from both job_instance and step_instance tables). Steven, can you test whether running with M5-snapshot solves the problem?
        Hide
        steven added a comment -

        After I upgraded to spring-batch-core-1.0.0.m5-20080216.020455-13, the problem has gone away.

        Thanks.

        Show
        steven added a comment - After I upgraded to spring-batch-core-1.0.0.m5-20080216.020455-13, the problem has gone away. Thanks.
        Hide
        Dave Syer added a comment -

        Assume closed as resolved and released

        Show
        Dave Syer added a comment - Assume closed as resolved and released

          People

          • Assignee:
            Robert Kasanicky
            Reporter:
            steven
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1h
              1h
              Remaining:
              Remaining Estimate - 1h
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified