filmov
tv
java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java
Показать описание
java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java
5 Steps to connect to the database
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-3 : Create the statement or prepared statement object
The createStatement() method of Connection interface is used to create statement..
Step-4 : Execute SQL
The executeQuery()/executeUpdate() method of Statement interface is used to execute queries.
Step-5 : close the database connection
The close() method of Connection interface is used to close the connection.
Download the source code
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;
Credit goes to our subscriber Sasi K :)
Please subscribe okay java.. thank you
5 Steps to connect to the database
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-3 : Create the statement or prepared statement object
The createStatement() method of Connection interface is used to create statement..
Step-4 : Execute SQL
The executeQuery()/executeUpdate() method of Statement interface is used to execute queries.
Step-5 : close the database connection
The close() method of Connection interface is used to close the connection.
Download the source code
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;
Credit goes to our subscriber Sasi K :)
Please subscribe okay java.. thank you