I am trying to insert multiple rows into Oracle table using prepared statement executebatch... I get the java.sql.BatchUpdateException: invalid argument(s) in call exception and my connection doesn't have a problem.. it's working in all other functions.....
I searched on the net and found invalid arguments in call only for java.sql.SQLException but not for BatchUpdateException.
Any help would be really appreciated.
public void insert(List<Employee> str, Connection con) throws SQLException {
String sql = "insert into tbl_list(e_name,e_id) values (?,?)";
PreparedStatement ps = con.prepareStatement(sql);
con.setAutoCommit(false);
for (int i = 1; i <= str.size(); i++) {
ps.setString(1, str.get(i - 1).getName());
ps.setString(2, str.get(i - 1).getId());
ps.addBatch();
}
ps.executeBatch();
ps.close();
con.close();
}
The stacktrace is:
May 16, 2017 2:34:40 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [spring] in context with path [/insert] threw exception [Request processing failed; nested exception is java.sql.BatchUpdateException: invalid arguments in call] with root cause java.sql.BatchUpdateException: invalid arguments in call at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10345) at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:230) at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297) at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297) at dao.insert.preparedInsert(insert.java:322)
insert.java :322 is ps.executeBatch();
Employeeclass?