MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

JDBC

JDBC Projects

JDBC Project 1

JDBC Using Statement example Batch Update
Previous Home Next
/* This example shows you how to insert few records in 
batch process via JDBC statement.*/

package r4r;
import java.sql.*;
import java.util.*;
public class BatchUpdate {
public static void main(String[] args) 
{
try
{
Scanner in=new Scanner(System.in);
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
Statement stmt=con.createStatement();
while(true)
{
System.out.println("Enter name:-");
String n=in.nextLine();
System.out.println("Enter id:-");
int i=in.nextInt();
in.nextLine();
System.out.println("Enter city:-");
String c=in.nextLine();
System.out.println("Enter sex:-");
String se=in.nextLine();
stmt.addBatch("insert into user5 values('"+n+"','"+i+"','"+c+"','"+se+"')");
System.out.println("Want to save more object,YES/NO");
String ans=in.nextLine();
if(ans.equals("no"))
break;
}
stmt.executeBatch();
System.out.println("successfully added batch");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

 

output:

Enter name:-
harsh
Enter id:-
5
Enter city:-
delhi
Enter sex:-
m
Want to save more object,YES/NO
yes

Enter name:-
rajesh
Enter id:-
7
Enter city:-
noida
Enter sex:-
m
Want to save more object,YES/NO
no
successfully added batch
Previous Home Next