This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

batchUpdate problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
}

 
Marshal
Posts: 22461
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic