SlideShare a Scribd company logo
1 of 2
Batch processing Demo
package com.nt.batch;
importjava.sql.*;
publicclassBatchProcessingDemo{
publicstaticvoidmain(String[] args) throwsException{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","password");
//create Statementobj
Statement st=con.createStatement();
//addqueriestobatch
st.addBatch("update studentsetsname='hritik'where sno=101");
st.addBatch("insertintostudentvalues(102,'ram',90,50,40,'hyderabad')");
st.addBatch("deletefromstudentwhere sno=104");
//execute the batch
int[] result=st.executeBatch();
//processthe result
intsum=0;//concept--- local variablesmusttobe initialized..
for(inti=0;i<result.length;++i){
sum=sum+result[i];
}
System.out.println("updationoccoured");
System.out.println("thenoof effectedresultsare:"+sum);
//close jdbcobjects
st.close();
con.close();
}catch(Exceptione){e.printStackTrace();}
}
}

More Related Content

What's hot

第三回月次セミナー(公開版)
第三回月次セミナー(公開版)第三回月次セミナー(公開版)
第三回月次セミナー(公開版)moai kids
 
Node child process
Node child processNode child process
Node child processLearningTech
 
Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Stuart Leeks
 
Taking a Test Drive
Taking a Test DriveTaking a Test Drive
Taking a Test DriveGraham Lee
 
Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]JavaScript Meetup HCMC
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingJungMinSEO5
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandraKazutaka Tomita
 
Node.js flow control
Node.js flow controlNode.js flow control
Node.js flow controlSimon Su
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsTimur Shemsedinov
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesOdoo
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?장현 한
 
Structured Testing Framework
Structured Testing FrameworkStructured Testing Framework
Structured Testing Frameworkserzar
 

What's hot (20)

第三回月次セミナー(公開版)
第三回月次セミナー(公開版)第三回月次セミナー(公開版)
第三回月次セミナー(公開版)
 
Node child process
Node child processNode child process
Node child process
 
Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018Azure Durable Funkiness - .NET Oxford June 2018
Azure Durable Funkiness - .NET Oxford June 2018
 
Taking a Test Drive
Taking a Test DriveTaking a Test Drive
Taking a Test Drive
 
Test innode
Test innodeTest innode
Test innode
 
CONTOH MEMBUAT TABEL XAMPP
CONTOH MEMBUAT TABEL XAMPPCONTOH MEMBUAT TABEL XAMPP
CONTOH MEMBUAT TABEL XAMPP
 
Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
What is row level isolation on cassandra
What is row level isolation on cassandraWhat is row level isolation on cassandra
What is row level isolation on cassandra
 
Gevent rabbit rpc
Gevent rabbit rpcGevent rabbit rpc
Gevent rabbit rpc
 
Node.js flow control
Node.js flow controlNode.js flow control
Node.js flow control
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your Modules
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?
 
Varnish
VarnishVarnish
Varnish
 
...Lag
...Lag...Lag
...Lag
 
Debugging TV Frame 0x09
Debugging TV Frame 0x09Debugging TV Frame 0x09
Debugging TV Frame 0x09
 
Insertion Sort Classe Principal
Insertion Sort Classe PrincipalInsertion Sort Classe Principal
Insertion Sort Classe Principal
 
Structured Testing Framework
Structured Testing FrameworkStructured Testing Framework
Structured Testing Framework
 

Similar to Batch processing Demo

Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management ToolPeeyush Ranjan
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Zianed Hou
 
Photo Insert and Retrieve App
Photo Insert and Retrieve AppPhoto Insert and Retrieve App
Photo Insert and Retrieve AppPeeyush Ranjan
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
Wwe Management System
Wwe Management SystemWwe Management System
Wwe Management SystemNeerajMudgal1
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APIcaswenson
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트기룡 남
 
Java assgn
Java assgnJava assgn
Java assgnaa11bb11
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
Db examples
Db examplesDb examples
Db examplesABDUmomo
 

Similar to Batch processing Demo (20)

Scrollable Test App
Scrollable Test AppScrollable Test App
Scrollable Test App
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
 
Cursor Demo App
Cursor Demo AppCursor Demo App
Cursor Demo App
 
Jdbc
JdbcJdbc
Jdbc
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 
Photo Insert and Retrieve App
Photo Insert and Retrieve AppPhoto Insert and Retrieve App
Photo Insert and Retrieve App
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
Wwe Management System
Wwe Management SystemWwe Management System
Wwe Management System
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트
 
Java assgn
Java assgnJava assgn
Java assgn
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Import java
Import javaImport java
Import java
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
Db examples
Db examplesDb examples
Db examples
 
Jdbc
JdbcJdbc
Jdbc
 

More from Peeyush Ranjan

More from Peeyush Ranjan (8)

Multiple Submit Button Test App
Multiple Submit Button Test AppMultiple Submit Button Test App
Multiple Submit Button Test App
 
Multiple Hyperlinks App
Multiple Hyperlinks AppMultiple Hyperlinks App
Multiple Hyperlinks App
 
Servlet LifeCycle Demo App
Servlet LifeCycle Demo  AppServlet LifeCycle Demo  App
Servlet LifeCycle Demo App
 
Online Form Submission App
Online Form Submission AppOnline Form Submission App
Online Form Submission App
 
Scrollable Demo App
Scrollable Demo AppScrollable Demo App
Scrollable Demo App
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
 
TextSearch
TextSearchTextSearch
TextSearch
 
DBTool
DBToolDBTool
DBTool
 

Batch processing Demo

  • 1. Batch processing Demo package com.nt.batch; importjava.sql.*; publicclassBatchProcessingDemo{ publicstaticvoidmain(String[] args) throwsException{ try{ Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","password"); //create Statementobj Statement st=con.createStatement(); //addqueriestobatch st.addBatch("update studentsetsname='hritik'where sno=101"); st.addBatch("insertintostudentvalues(102,'ram',90,50,40,'hyderabad')"); st.addBatch("deletefromstudentwhere sno=104"); //execute the batch int[] result=st.executeBatch(); //processthe result intsum=0;//concept--- local variablesmusttobe initialized.. for(inti=0;i<result.length;++i){ sum=sum+result[i]; } System.out.println("updationoccoured"); System.out.println("thenoof effectedresultsare:"+sum); //close jdbcobjects