Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

batchUpdate problem

 
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();
}
}
}

 
Sheriff
Posts: 22028
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic