java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java
Buy me a coffee - https://www.buymeacoffee.com/okayjava
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
https://gitlab.com/okay-java/mysql-jd...
Download mysql driver
https://dbschema.com/jdbc-driver/MySq...
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;
insert into user values (1, 'adam', 'kia', 'adam@kia.com', 'abcd@1234', '2021-12-25', 'M');
insert into user values (2, 'david', 'gill', 'david@gill.com', 'gill@1234', '2021-10-25', 'M');
insert into user values (3, 'watson', 'light', 'watson@light.com', 'ligh@1234', '2021-11-25', 'M');
insert into user values (4, 'kara', 'joraell', 'kara@jora.com', 'kara@1234', '2021-12-25', 'M');
insert into user values (5, 'alex', 'danvers', 'alex@deo.com', 'alex@1234', '2021-12-25', 'M');
Credit goes to our subscriber Sasi K :)
Please subscribe okay java.. thank you
Sur cette page du site, vous pouvez voir la vidéo en ligne java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur okay java 08 janvier 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,447 fois et il a aimé 16 téléspectateurs. Bon visionnage!