我试图使用预处理语句将行插入到oracle数据库中。但无法将数据存储在db中,并且不会显示任何错误。我是春季班的新手。是否可以使用休眠进行插入。
<beans:bean id="databaseItemWriter"
class="org.springframework.batch.item.database.JdbcBatchItemWriter">
<beans:property name="dataSource" ref="dataSource" ></beans:property>
<beans:property name="sql">
<beans:value>
<![CDATA[
insert into BLOOD_BANK(NAME, ADDRESS, BLOOD_GROUP)
values (?,?,?)
]]>
</beans:value>
</beans:property>
<beans:property name="ItemPreparedStatementSetter">
<beans:bean class="com.ibs.training.PreparedStatementSetter" />
preparedStatementetter
@Override public void setValues(Model item, PreparedStatement ps) throws SQLException { ps.setString(1,"nismath"); ps.setString(2, "kochi"); ps.setString(3,"a"); }
数据库连接
<!-- data base connection -->
<beans:bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">
<beans:property name="URL"
value="jdbc:oracle:thin:@localhost:1521:xe" />
<beans:property name="user" value="user_04" />
<beans:property name="password" value="user" />
</beans:bean>
<beans:bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<beans:property name="dataSource" ref="dataSource"></beans:property>
</beans:bean>