filmov
tv
java jdbc batch | batch execution | batch processing | okay java

Показать описание
java jdbc batch | batch execution | batch processing | okay java
download the source code
Steps
Step -1 : Register the driver
The forName() method of Class is used to register the driver class (dynamically load the driver class)
Step-2 : Create the database connection
The getConnection() method of DriverManager class is used to establish connection with the database.
Step-4 : Create the statement or prepared statement object
The createStatement() method of Connection interface is used to create statement..
Step-5: Write SQLs
String sql4 = "update user set firstname='supergirl' where id = 3";
String sql5 = "delete from user where id = 1";
Step-6 : Add SQLs to batch by using addBatch()
Step-7 : Run the batch by calling executeBatch()
Step-8 : Commit the transaction to the database by calling commit() function
Step-9 : Close the database connection
The close() method of Connection interface is used to close the connection.
Download mysql driver
Login to mysql database server
mysql -u root -p
--- create database
create database userdb;
use userdb;
create table user(id int not null auto_increment,
firstname varchar(50),
lastname varchar(50),
email varchar(50),
password varchar(10),
birth_date date,
gender char(1),
primary key(id));
show tables;
describe user;
download the source code
Steps
Step -1 : Register the driver
The forName() method of Class is used to register the driver class (dynamically load the driver class)
Step-2 : Create the database connection
The getConnection() method of DriverManager class is used to establish connection with the database.
Step-4 : Create the statement or prepared statement object
The createStatement() method of Connection interface is used to create statement..
Step-5: Write SQLs
String sql4 = "update user set firstname='supergirl' where id = 3";
String sql5 = "delete from user where id = 1";
Step-6 : Add SQLs to batch by using addBatch()
Step-7 : Run the batch by calling executeBatch()
Step-8 : Commit the transaction to the database by calling commit() function
Step-9 : Close the database connection
The close() method of Connection interface is used to close the connection.
Download mysql driver
Login to mysql database server
mysql -u root -p
--- create database
create database userdb;
use userdb;
create table user(id int not null auto_increment,
firstname varchar(50),
lastname varchar(50),
email varchar(50),
password varchar(10),
birth_date date,
gender char(1),
primary key(id));
show tables;
describe user;