This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

batchUpdate problem

 
Mike Calbor
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

ok so i am doing this project from roseindia on batchUpdate(Strings []) and getting this error.
I have already imported most of the required jars in the build path thing of the eclipse. I am using Spring and JDBC to update the database.
When i am trying to code it i am getting this error

" Multiple markers at this line
- The method batchUpdate(String[]) from the type JdbcTemplate refers to the missing type DataAccessException
- The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files."

I am not sure what needs to be done.

code where i am getting the error is


jt.batchUpdate(new String[]{"update Details set department = 'Finance#'",
"delete from Details where EmployeeId =31"});


and the entire code is





"import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;

class Main {
public static void main(String args[]) {
try {
ApplicationContext ac = new
ClassPathXmlApplicationContext("context.xml", Main.class);
DataSource source = (DataSource) ac.getBean("dataSource");
JdbcTemplate jt = new JdbcTemplate(source);
jt.batchUpdate(new String[]{"update Details set department = 'Finance#'",
"delete from Details where EmployeeId =31"});
System.out.println("Data updated successfully");
} catch (Exception e) {
e.printStackTrace();
}
}
}

 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Mike Calbor wrote:I have already imported most of the required jars in the build path thing of the eclipse. I am using Spring and JDBC to update the database.
When i am trying to code it i am getting this error

" Multiple markers at this line
- The method batchUpdate(String[]) from the type JdbcTemplate refers to the missing type DataAccessException
- The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files."

I am not sure what needs to be done.

It's not your code that's giving the problems, it's your project build path. You have added all the JAR files you require directly. One of these has a dependency of its own that Eclipse apparently needs. You'll need to add the JAR file that includes the org.springframework.dao.DataAccessException class to your project's build path as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic