JdbcTemplate.batchUpdate не применимая ошибкаJAVA

Программисты JAVA общаются здесь
Гость
JdbcTemplate.batchUpdate не применимая ошибка

Сообщение Гость »

Код: Выделить всё

    public void insert(List students) {

String sql ="INSERT INTO sqlDB.Student VALUES(?,?,?)";

ArrayList sqlargs=new ArrayList();

for(Student tempstudent: students) {

Object[] studentData={tempstudent.getRollNo(),tempstudent.getName(),tempstudent.getAddress()};

sqlargs.add(studentData);
}

jdbcTemplate.batchUpdate(sql, sqlargs);

System.out.println("Batch Update Completed-->");
}
Error:
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
ApplicationContext is Loaded
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method batchUpdate(String, BatchPreparedStatementSetter) in the type JdbcTemplate is not applicable for the arguments (String, ArrayList)

Код: Выделить всё

at com.jdbc.dao.StudentDAOimpl.insert(StudentDAOimpl.java:76)
at com.jdbc.service.StudentDAOHelper.setUpStudentTable(StudentDAOHelper.java:35)
at com.jdbc.test.Runner.main(Runner.java:21)
I was trying to insert a batch of student data into the database using jdbcTemplate.batchUpdate(), this is my method and the error i'm getting. as of now i only learned about Spring and jdbc, is there any other way of using batchupdate interface.


Источник: https://stackoverflow.com/questions/781 ... able-error

Вернуться в «JAVA»