Spring批处理,无法在oracle数据库上编写

问题描述 投票:0回答:1

这是我的xml文件配置。

    <batch:job id="pdgRecallJob">
        <batch:step id="stepTmpRecall">
            <batch:tasklet>
                <batch:chunk reader="readFileRecall" processor="" writer="tmpRecallWriter" commit-interval="10000">
                </batch:chunk>
            </batch:tasklet>
        </batch:step>
    </batch:job>



    <bean id="tmpRecall" class="it.mef.pdg.batch.model.TmpRecall" scope="prototype" />


    <bean id="readFileRecall" class="org.springframework.batch.item.file.FlatFileItemReader">

        <property name="strict" value="false" />
        <property name="resource" value="classpath:/properties/RECALLPDG_*.txt"/>
        <property name="lineMapper">
        <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
          <property name="lineTokenizer">
            <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
                <property name="delimiter" value=";"/>
                <property name="names" value="appNomeFile, appCodFisc, appRata, appImporto, appIscrizione, appNumTitolo, 
                appProgQuota, appAnnoEmissione, appCodEnte, appEsitoMef, appStatoFile, appDpt, appPostazione, appNLotto, 
                appDLotto, appNomeFileOrigine" />
            </bean>
          </property>
          <property name="fieldSetMapper">   
              <bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
                    <property name="prototypeBeanName" value="tmpRecall" />
              </bean>           
          </property>
        </bean>
        </property>

    </bean>


    <bean id="tmpRecallWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">

        <property name="dataSource" ref="dataSource" />
        <property name="sql">
            <value>
            <![CDATA[
                INSERT INTO APP_TMP_RECALL(APP_NOME_FILE,APP_COD_FISC,APP_RATA,APP_IMPORTO,APP_ISCRIZIONE,APP_NUM_TITOLO,APP_PROGR_QUOTA,APP_ANNO_EMISSIONE,APP_COD_ENTE,APP_ESITO_MEF,APP_STATO_FILE,APP_DPT,APP_POSTAZIONE,APP_NLOTTO,APP_DLOTTO,APP_NOME_FILE_ORIGINE)
                VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
            ]]>
            </value>

        </property>

        <property name="itemPreparedStatementSetter">
            <bean class="it.mef.pdg.batch.items.TmpRecallPreparedStatementSetter" />
        </property>

    </bean>     

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource" />
    </bean>


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
        <property name="url" value="${db.url}" />
        <property name="username" value="${db.user}" />
        <property name="password" value="${db.pass}" />
    </bean>

然后我的itemPreparedStatementSetter类:

final class TmpRecallPreparedStatementSetter implements ItemPreparedStatementSetter<TmpRecall>{

public void setValues(TmpRecall tmp, PreparedStatement ps) throws SQLException {

    ps.setString(1, tmp.getAppNomeFile());
    ps.setString(2, tmp.getAppCodFisc());
    ps.setInt(3, tmp.getAppRata());
    ps.setDouble(4, tmp.getAppImporto());
    ps.setString(5, tmp.getAppIscrizione());
    ps.setInt(6, tmp.getAppNumTitolo());
    ps.setString(7, tmp.getAppProgQuota());
    ps.setInt(8, tmp.getAppAnnoEmissione());
    ps.setString(9, tmp.getAppCodEnte());
    ps.setString(10, tmp.getAppEsitoMef());
    ps.setString(11, tmp.getAppStatoFile());
    ps.setString(12, tmp.getAppDpt());
    ps.setInt(13, tmp.getAppPostazione());
    ps.setInt(14, tmp.getAppNLotto());
    ps.setDate(15, tmp.getAppDLotto());
    ps.setInt(16, tmp.getAppNLotto());


}

}

我的批处理似乎工作,然后我的最终状态为COMPLETED,但它不会在我的表中写入任何记录。

我正在使用jdk 1.5,ojdbc5-11.2.0.3.jar。

要么我的xml conf中缺少一些东西,要么任何bean都不行?

我当时认为表格中的Date字段可能甚至不匹配。

database spring oracle spring-batch
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.