Click here to watch on Youtube:
https://www.youtube.com/watch?v=J4uwf_2l2PQ&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge:
Employee.sql
pom.xml
EmployeeDAO.java
EmployeeDAOImpl.java
App.java
Output:
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/SpringDemo_delete_multi_param_object_array.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Spring_2019/SpringDemo_delete_multi_param_object_array
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/8f8b5563b7f2921ed260908e4906103995d9c6cc/Spring_2019/SpringDemo_delete_multi_param_object_array/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Spring Tutorial
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
Cooking Tutorial
https://www.youtube.com/watch?v=J4uwf_2l2PQ&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge:
Spring + JdbcTemplate + Execute delete statement with multiple parameters with object array example |
Employee.sql
CREATE DATABASE org_db;
CREATE TABLE `employee` (
`EMPLOYEE_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`NAME` VARCHAR(100) NOT NULL,
`AGE` INT(10) NOT NULL,
`SALARY` INT(10) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`)
) ENGINE=INNODB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('1','Peter','28','80000');
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('2','John','50','40000');
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('3','David','45','20000');
CREATE TABLE `employee` (
`EMPLOYEE_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`NAME` VARCHAR(100) NOT NULL,
`AGE` INT(10) NOT NULL,
`SALARY` INT(10) DEFAULT NULL,
PRIMARY KEY (`EMPLOYEE_ID`)
) ENGINE=INNODB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('1','Peter','28','80000');
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('2','John','50','40000');
INSERT INTO `employee` (`EMPLOYEE_ID`, `NAME`, `AGE`, `SALARY`) VALUES('3','David','45','20000');
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ram.core</groupId>
<artifactId>SpringDemo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringDemo</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>5.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring 5 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
</dependencies>
</project>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ram.core</groupId>
<artifactId>SpringDemo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringDemo</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>5.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring 5 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
</dependencies>
</project>
EmployeeDAO.java
package com.ram.employee.dao;
public interface EmployeeDAO
{
public int deleteByEmployeeNameAndAge(String name,int age);
}
public interface EmployeeDAO
{
public int deleteByEmployeeNameAndAge(String name,int age);
}
EmployeeDAOImpl.java
package com.ram.employee.dao.impl;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.ram.employee.dao.EmployeeDAO;
public class EmployeeDAOImpl extends JdbcDaoSupport implements EmployeeDAO
{
public int deleteByEmployeeNameAndAge(String name, int age)
{
String sql = "DELETE FROM EMPLOYEE WHERE Name=? and AGE=?";
int numberOfRowsAffected = getJdbcTemplate().update(sql,
new Object[] { name, age });
return numberOfRowsAffected;
}
}
applicationContext.xmlimport org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.ram.employee.dao.EmployeeDAO;
public class EmployeeDAOImpl extends JdbcDaoSupport implements EmployeeDAO
{
public int deleteByEmployeeNameAndAge(String name, int age)
{
String sql = "DELETE FROM EMPLOYEE WHERE Name=? and AGE=?";
int numberOfRowsAffected = getJdbcTemplate().update(sql,
new Object[] { name, age });
return numberOfRowsAffected;
}
}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/org_db" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<bean id="employeeDAO" class="com.ram.employee.dao.impl.EmployeeDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/org_db" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<bean id="employeeDAO" class="com.ram.employee.dao.impl.EmployeeDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
App.java
package com.ram.core;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ram.employee.dao.EmployeeDAO;
public class App
{
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
EmployeeDAO employeeDAO = (EmployeeDAO) context
.getBean("employeeDAO");
int numberOfRowsAffected = employeeDAO.deleteByEmployeeNameAndAge("John",50);
System.out.println(numberOfRowsAffected + " employee row deleted successfully.");
}
}
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ram.employee.dao.EmployeeDAO;
public class App
{
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
EmployeeDAO employeeDAO = (EmployeeDAO) context
.getBean("employeeDAO");
int numberOfRowsAffected = employeeDAO.deleteByEmployeeNameAndAge("John",50);
System.out.println(numberOfRowsAffected + " employee row deleted successfully.");
}
}
Output:
Feb 11, 2019 10:51:56 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@35d176f7: startup date [Mon Feb 11 10:51:56 IST 2019]; root of context hierarchy
Feb 11, 2019 10:51:56 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Feb 11, 2019 10:51:57 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Mon Feb 11 10:52:06 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
1 employee row deleted successfully.
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@35d176f7: startup date [Mon Feb 11 10:51:56 IST 2019]; root of context hierarchy
Feb 11, 2019 10:51:56 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Feb 11, 2019 10:51:57 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Mon Feb 11 10:52:06 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
1 employee row deleted successfully.
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/SpringDemo_delete_multi_param_object_array.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Spring_2019/SpringDemo_delete_multi_param_object_array
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/8f8b5563b7f2921ed260908e4906103995d9c6cc/Spring_2019/SpringDemo_delete_multi_param_object_array/?at=master
See also:
There is large and wide scope for this technologies.Today majority of the frameworks, software are running on java and java is running rapidly .
ReplyDeleteRegards
it is the easy way to understand the code thanking you it is help full
ReplyDeleteAzure Data Factory course in Ameerpet
Azure Data Engineer Training Online Hyderabad
azure training in hyderabad ameerpet
Azure Data Factory online Training in Hyderabad
Microsoft Azure Data Factory in hyderabad
Microsoft Azure is an operating system that allows you to create web applications and store data in the cloud.Azure admin training in hyderabad visit our link to get more information:-https://azuretrainings.in/
ReplyDeleteThis post is so interactive and informative.keep update more information...
ReplyDeleteThanks For Sharing The Information The Information Shared Is Very Valuable Please Keep Updating Us By eMexo Technologies
Java Training in Electronic City Bangalore
Java Course in Electronic City Bangalore
Best Java Training Institute in Electronic City Bangalore
Java Certification Training in Electronic City Bangalore
Java Training in Electronic City
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteDigital marketing Online Training
Digital marketing Training
Digital marketing Online Training in Hyderabad
Digital marketing Online Training institute
Digital marketing Training institute in Ameerpet
Digital marketing Training in Hyderabad
Digital marketingTraining Classes
Digital marketing Training in Ameerpet
Digital marketing Training institute in Hyderabad
Digital marketing Course in Hyderabad
Digital marketing Training Online
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteDigital marketing Online Training
Digital marketing Training
Digital marketing Online Training in Hyderabad
Digital marketing Online Training institute
Digital marketing Training institute in Ameerpet
Digital marketing Training in Hyderabad
Digital marketingTraining Classes
Digital marketing Training in Ameerpet
Digital marketing Training institute in Hyderabad
Digital marketing Course in Hyderabad
Digital marketing Training Online
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteDigital marketing Online Training
Digital marketing Training
Digital marketing Online Training in Hyderabad
Digital marketing Online Training institute
Digital marketing Training institute in Ameerpet
Digital marketing Training in Hyderabad
Digital marketingTraining Classes
Digital marketing Training in Ameerpet
Digital marketing Training institute in Hyderabad
Digital marketing Course in Hyderabad
Digital marketing Training Online
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteadf Online Training in Hyderabad
adf Online Training institute
azure data factory Training institute in Ameerpet
adf Training in Hyderabad
adf Training Classes
azure data factory Training in Ameerpet
adf Training institute in Hyderabad
adf Course in Hyderabad
azure data factory Training Online
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteDigital marketing Online Training
Digital marketing Training
Digital marketing Online Training in Hyderabad
Digital marketing Online Training institute
Digital marketing Training institute in Ameerpet
Digital marketing Training in Hyderabad
Digital marketingTraining Classes
Digital marketing Training in Ameerpet
Digital marketing Training institute in Hyderabad
Digital marketing Course in Hyderabad
Digital marketing Training Online
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Please also visit my site.
ReplyDeleteadf Online Training in Hyderabad
adf Online Training institute
azure data factory Training institute in Ameerpet
adf Training in Hyderabad
adf Training Classes
azure data factory Training in Ameerpet
adf Training institute in Hyderabad
adf Course in Hyderabad
azure data factory Training Online
Hello Sir I saw your blog, It was very nice blog, and your blog content is awesome. Digital Marketing
ReplyDeleteThank you for the Valuable information
ReplyDeleteCheck our online certification courses and get certified
Project Management Techniques
Check our online certification courses and get certified
ReplyDeleteLean Six Sigma Green Belt certification training program
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP certification from our expert training
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP certification from our expert training
Thank you for the Valuable information
ReplyDeleteCheck our online certification courses and get certified
Project Management Techniques
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Thank you for the Valuable information
ReplyDeleteCheck our online certification courses and get certified
Project Management Techniques
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Good information
ReplyDeleteCheck our online certification courses and get certified
PMP Certification training online
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck our online certification courses and get certified
Project Management Techniques
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Hey, your article is really good and helpful, keep up the good work.
ReplyDeleteSoftware Development Company
Software Development Noida Delhi
ERP Software Companies in Delhi Noida
Thanks for sharing amazing information. Are you looking for reliable search engine marketing services India? There is no need to look any further! Our professionals can assist you in increasing your internet exposure and driving more visitors to your website. To learn more, please contact us immediately.
ReplyDeletegood information.Azure Classes in Pune
ReplyDeletegood information. Azure Classes in Pune
ReplyDeleteNice Article
ReplyDeleteThanks for sharing with us 🙂
Java Full Stack Developer Course in Hyderabad
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Nice article.keep posting.
ReplyDeleteAngular js course in Hyderabad
Your blog post is insightful and well-researched. It provides valuable information and practical tips that are highly relevant. The clear writing style makes complex concepts easy to understand. I look forward to reading more from your blog in the future. Keep up the great work. If you are looking for professional Job oriented course like
ReplyDeletePython Training in noida
Data Science Training in noida
full stack development training in noida
Software Testing Training in Noida
Digital Marketing Training in Noida
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Thank you for the Valuable information
ReplyDeleteCheck out our Certification Programs :
Events in scrum
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Full Stack Developer Course in Hyderabad
Thank you for sharing! I always appreciate engaging content with valuable insights. The presented ideas are not only excellent but also captivating, making the post thoroughly enjoyable. Your continued efforts are commendable. Keep up the fantastic work.
ReplyDeletevisit: Python in the Cloud: Deploying Apps with AWS and Azure
SQL Training In Hyderabad
ReplyDeletebest SQL training institute in hyderabad
SQL online Training in hyderabad
SQL training in ameerpet
SQL server Training in Hyderabad
sql Training
sql Online Training
sql server Online Training in Hyderabad
sql Online Training institute
sql server Training institute in Ameerpet
sql server Course in Hyderabad
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Full Stack Course in Hyderabad
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Azure Data Factory Training In Hyderabad
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Business Analyst Coaching in Hyderabad
Thanks for sharing with us 🙂
ReplyDeleteBest Digital Marketing Company In Surat
Best Laravel Development Company In Surat
Best Web Design Agency In Surat
Best WordPress Development Company In Surat
I'm obliged for the blog article. Thanks Again. Awesome.
ReplyDeleteAngular Online Training from USA, Uk, Australia, UAE, Canada
Full Stack Web Development Certification Training In India
Manual Testing Online Training from Chennai
Tibco BW 6.x Training Institute In Bangalore
Teradata Online Coaching In Australia
ASP .Net MVC Online Course from India
Android Development Online Training Coaching
Thanks for good information
ReplyDeleteDigital Marketing Course in Surat
ReplyDeleteThans for the good information
Digital Marketing Course in Surat
I enjoyed reading this post because it was so well-written and informative! I learned a lot from it.
ReplyDeleteSpring Boot Certification Training Course In Electronic City Bangalore
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Full Stack Training In Hyderabad
Nice Article!
ReplyDeleteThanks for sharing with us 🙂
Full Stack Training In Hyderabad
Very impressive post. Thanks for sharing.
ReplyDeleteclick here for more information
ReplyDeleteThis blog post is incredibly useful and instructive. I want to thank you for sharing this information. I also have a website with a lot of useful information.
Manual testing Training in hyderabad
Very impressive post. Thanks for sharing.
ReplyDeleteclick here for more information
Thank you so much for sharing this information with us. Its a great article to help other understand the concepts in a much easier way.
ReplyDeleteclick here for more information