java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java

Veröffentlicht am: 08 Januar 2022
auf dem Kanal: okay java
1,447
16

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


Auf dieser Seite können Sie das Online-Video java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer okay java 08 Januar 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,447 Mal angesehen und es wurde von 16 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!