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
In questa pagina del sito puoi guardare il video online java jdbc | jdbc mysql database | java database connectivity | 5 steps | okay java della durata di ore minuti seconda in buona qualità , che l'utente ha caricato okay java 08 gennaio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,447 volte e gli è piaciuto 16 spettatori. Buona visione!