上面代码中的问题是什么? 我需要更改以使代码成功运行。 我需要改变什么
$sql = "SELECT *
FROM `characteritem`
INNER JOIN item ON characteritem.iid=item.iid
WHERE `owner` = '$user'";
$result = $db_conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$iid = $row['characteritem.iid'];
$quantity = $row['quantity'];
$itemweight = $row['itemweight'];
$itemtotal = $itemweight * $quantity;
echo $itemtotal;
}
}
部分日志输出:
@Configuration
@EnableBatchProcessing
public class BatchConfiguration
{
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Autowired
private DataSource dataSource;
@Bean
public DataSource dataSource()
{
System.out.println("here1");
final DriverManagerDataSource dataSource =new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/ssk");
dataSource.setUsername("root");
dataSource.setPassword("hardik0000007");
return dataSource;
}
@Bean
public FlatFileItemReader<people> reader()
{
System.out.println("here2");
FlatFileItemReader<people> reader =new FlatFileItemReader<people>();
reader.setResource(new ClassPathResource("employeeData.csv"));
reader.setLineMapper(new DefaultLineMapper<people>(){{
setLineTokenizer(new DelimitedLineTokenizer(){{
setNames(new String[]{"fname","lname"});
}});
setFieldSetMapper(new BeanWrapperFieldSetMapper<people>(){{
setTargetType(people.class);
}});
}});
return reader;
}
@Bean
public UserItemProcessor processor()
{
System.out.println("here3");
return new UserItemProcessor();
}
@Bean
public JdbcBatchItemWriter<people> writer()
{
System.out.println("here4");
JdbcBatchItemWriter<people> writer =new JdbcBatchItemWriter<people>();
writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<people>());
writer.setSql("Insert into people (first_name,last_name) values (:fname,:lname)");
writer.setDataSource(dataSource);
return writer;
}
@Bean
public Step step1()
{
System.out.println("here5");
return stepBuilderFactory.get("step1").<people,people> chunk(3).
reader(reader()).
processor(processor()).
writer(writer())
.build();
}
@Bean
public Job importUserJob()
{
System.out.println("here6");
return jobBuilderFactory.get("importUserJob").
incrementer(new RunIdIncrementer()).
flow(step1()).
end().
build();
}
}