WEBVTT

00:00.000 --> 00:08.080
data bases to Java applications using JDBC.

00:08.080 --> 00:15.680
In this video, we will understand, create a table in MySQL and connect it using JDBC.

00:15.680 --> 00:25.800
Run SQL queries in Java using statement, insert and verify data from user input.

00:25.800 --> 00:31.320
In previous video, we have already seen the two steps of our Java database connectivity.

00:31.320 --> 00:36.520
So the first one was to import the package, then load and register the JDBC driver,

00:36.520 --> 00:41.080
and the second one was to establish a connection with the database.

00:41.080 --> 00:44.320
Creating table in JDBC.

00:44.320 --> 00:46.920
Now we will create a data table.

00:46.920 --> 00:49.800
For that, we need to open MySQL Workbench.

00:49.800 --> 00:52.200
We will type the show table.

00:52.200 --> 00:56.840
It will display a table here, then we will again return to the Eclipse workspace.

00:56.840 --> 01:04.960
Now we will type the command for the table.

01:04.960 --> 01:10.280
This command creates the table in the database with a table header and columns, name with

01:10.280 --> 01:13.640
a maximum 100 characters.

01:13.640 --> 01:21.480
VAR Char means variable characters, age with a maximum 10 numbers, int integers value

01:21.480 --> 01:26.240
0, 1, 2, 3.

01:26.240 --> 01:29.960
City with a maximum 100 characters.

01:29.960 --> 01:33.520
This line creates a statement object from the current database.

01:33.520 --> 01:38.880
This statement is to send the queries to the database like CRUD operations.

01:38.880 --> 01:45.160
These line executes the SQL queries stored in the variable create table.

01:45.160 --> 01:48.120
This prints the message in the console.

01:48.120 --> 01:54.840
Now in MySQL Workbench, checks the created table that describes the created table.

01:54.840 --> 01:58.080
JDBC insert data.

01:58.080 --> 02:01.120
Now we need to insert data into the table.

02:01.120 --> 02:10.920
We will type the code for that.

02:10.920 --> 02:16.440
Here the line creates a scanner object which is used to take input from the key B.

02:16.440 --> 02:20.640
This displays the message to the user in the console.

02:20.640 --> 02:26.840
This takes the input as a string and stores it in the table under the column name.

02:26.840 --> 02:33.320
Similarly string age stores age data in the age column and string city stores city data

02:33.320 --> 02:35.400
in the city column.

02:35.400 --> 02:41.320
This line creates the SQL insert query and maps correctly into the column.

02:41.320 --> 02:44.480
This statement checks if the data is stored or not.

02:45.120 --> 02:47.680
Now let's see if our code runs.

02:47.680 --> 02:55.520
We have successfully inserted the table in JDBC.

02:55.520 --> 02:58.960
We created a table in MYSQL.

02:58.960 --> 03:02.800
Inserted data through Java and verified it in the database.

03:02.800 --> 03:11.040
This showed how JDBC connects Java programs with real databases and executes SQL command smoothly.

03:11.040 --> 03:15.120
You now know how Java sends queries and stores user entered data successfully.

