This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes batchUpdate problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "batchUpdate problem" Watch "batchUpdate problem" New topic
Author

batchUpdate problem

Mike Calbor
Greenhorn

Joined: Apr 08, 2011
Posts: 1
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

Joined: Oct 27, 2005
Posts: 19654
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: batchUpdate problem
 
Similar Threads
Connecting to Database using JDBC template (Spring)
Savepoint
Http Status 404 - Servlet DataAccessServlet is currently unavailable
JdbcTemplate and IllegalArgumentException
Spring - MySql Connectivity Error