0:01
Hi friends, welcome to tutors funny channel. Uh today I'm bring the video of
0:06
WP concept of Java. WP is a very crucial things in the programming language.
0:13
Those who wants to learn programming, you must study WP. If you are not
0:19
familiar in WP, you will not able to write the programming well. So you have to study WP well. So I bring the W OP
0:28
credit application step from the scratch. Okay. Okay. So you have to go
0:34
through the video and you have to learn WP how to make the credit application
0:40
you using WP in the efficient way and
0:46
how to design the UI design using Java swing application in efficient way. You
0:51
can study both from the scratch. You can watch it. Thank you.
0:57
Hi friends, welcome to tutors funny channel. Today I'm going to teach sales and target conf contribution
1:05
MVC OP project using Java swimming application. Now let me discuss right.
1:12
So here target and contribution. So if you are go for the company they given
1:18
the sales company they given the target. Okay. So the target have to complete the
1:24
target. So the here we have a contribution right. So, so you can see
1:29
target these are the attributes it have ID the target person name after that the
1:36
amount the date it's a complete right so the contribution asset
1:44
ID date amount and target these are the attributes we have right now let me
1:51
create this target and contribution tables so if you are not
1:57
If you have not installed the MySQL workbench in your machine, you have to install the MySQL workbench.
2:04
MySQL workbench workbench. Okay. Right. After that, we
2:12
have to install the Netb download net in the machine latest you
2:18
can download and install it. Right. Now, I already installed the MySQL workbench. I have to open it.
2:26
MySQL batch click on here I'm going to
2:32
type the username root password root 1 2 3 press enter key right now here I'm
2:39
going to create the database so database I'm going to create the database so you go here you can see
2:46
uh different tabs are there here you can go here to click on this first table this one here I'm going to create a new
2:52
database which is uh if C is a company. Okay, just see IFC
3:04
right now click right if you can see the IFC database has been created here right
3:12
this inside database we have created the table say the table right click new table now you can get it here you can
3:19
click on here okay you can you can add the columns first column what's the column is target so target is a column H
3:28
sorry target is a table name column first one is a ID which is a
3:33
target ID which is a primary key with auto increment okay we have to create
3:39
the auto increment we don't need to give the value it is ID is auto increment once the value is added ID will be auto
3:45
increment second one should be the name target name should be I have given the
3:51
as 255 right characters third one should be
3:57
per amount. The amount
4:03
this one should be given as a double.
4:10
Third one, fourth one should be uh date and time. Date
4:25
The date after that complete
4:31
this one should be given as a the active or not the complete the sales is active
4:38
or not. Okay, you just Okay, here you have select as a tint
4:50
Type it here. Got to get them here. Tiny
5:13
here default value given as here zero that default expression zero right
5:19
that's the thing you have to do it so it's a default one you have set we not add these two fields and not add the
5:24
values so Here we have to set asset zero right okay tiny values complete right so
5:31
these are things you have to create the table you have to make sure this all selection after that you have to click
5:37
apply apply finish your table has been created successfully here target table
5:42
has been created also right now I'm going to get another table which is a contribution create table contribution
5:49
contribution right here we We have to add the columns
5:57
ID which is a contribution ID primary key auto increment. Second one is here date
6:11
Third one should be our third field
6:16
amount target amount.
6:38
after that target ID which is a integer that's that's the field we have to set
6:44
it here right this is a foreign key the foreign key of the table target table
6:50
there is ID the same ID which will be coming the country table which is a foreign key. Right? Now we have to we
6:58
have to apply apply. Finish it. Right. Perfect. Now we have created the two
7:05
tables. We have to create now let's go to the net bins. Open the
7:13
net beans. Right now if you are doing the project in sewing application I
7:18
recommend that you have to do it as net beans. It's very simple. You have to configure the project, right? Okay.
7:26
Everyone uh who doing this uh project in swimming application in in uh net bins
7:36
Java FX you can use it as a intellig idea that is a best editor. Now you click file new project. I'm
7:44
going to create the sales sales target
8:07
sales target. If it is selected create uncheck it and
8:13
finish the project. Now your project has been created. You can see here your project has been
8:26
Here default here you can expand the project here default package here create the packages first package I'm going to
8:33
create java package I'm going to create first package I'm going to create this
8:39
one controller you have write like this
8:45
com. project controller. First I'm going to create the package. This is a controller package. This is MDC architecture I'm going to do in the
8:51
project. Second package I'm going to create new Java package. Second project I'm going to create this one as a model.
9:02
Third one create I'm going to create the package this here as
9:07
util. After that we have create another package. which is a
9:16
db after that I'm going to create another package which is a
9:25
view these are the packages we have okay mc
9:32
model controller db model util util can manage the date and everything date time
9:39
and all things db this package control the databases. This is a controller. This is a model, right? It's a model
9:47
disappear. The fuel part I'm going to create the right click, select the package new. I'm going to select a JF
9:54
form. I'm going to name it as a form. The name of form
10:04
right now here you have to expand that. If you double click on this, you can give the prices. So this right now here
10:12
what I'm going to do is I'm going to go to here first I'm going
10:26
under the swing heading the menu the file menu bar you have to drag and drop it here the menu bar click on this right
10:32
click you can see the event sorry you have to go to the select this menu
10:39
option. Right click uh pallet add palette. You can see here
10:45
the menu item. You can add the menu items over here. Here you can add the menu item. So here right click edit
10:50
text. Exit. Okay. If you want to the menu item here like this menu item, you
10:56
can add it here. Here. If you want another one, go here. Add pallet menu item. You can add another
11:03
menu item. You can do it like this if you need like this way. Here you can expand like this way. What you're going
11:09
to do is click on this. Click on this. There's a another thing
11:15
you can see the menus here. You can add the menus and you can expand this like this. The software you can uh you can
11:22
write like this. Okay, that's the thing you have to put right this menu this
11:27
main in Java programming. Right. After that I have to split out
11:33
this interface. sort out split out. You have to go to the area this
11:44
you can split out the area
11:54
in here split pan. So to select this split pan you have to drag and drop it
12:00
here. You can see here split pan you drag and drop it here. Click on this one. I think
12:05
you have to write like this. Here this is split pan right
12:11
this size right. So you have to click right. So you have to write here is
12:18
split. Okay. You have to write like this. Now you can see here I want to this your
12:24
left left side. You have to increase the size little bit bigger here. Okay. We need a width. Right. So what how to how
12:31
to increase width here you have to you have to go to the here the split pan this is split pan so you have to go to
12:38
the navigator pan navigator pan here this you have there are two pans panel
12:45
one panel two you have to select the main one splitter splitter you have to select this splitter this is a splitter
12:51
you have to go to the location here divided location I'm going to increase as 200
12:57
percentage now you can see here if you feel it is too much you have to little
13:03
bit you have to select again that's 150 170 it will be the perfect
13:10
one I think press enter key now you can see here it's okay right perfect now here you can
13:17
drag the button and all now let's execute the program and check it
13:27
it's working it's working perfectly working now here it's working perfectly
13:32
well right here I can select this one properties
13:41
right so it's working perfectly well right now let's select the panel I'm
13:49
going to code generate center and here
13:54
go to the source control F UI I would select this one as a matter
14:02
that's a perfect one. Now again I'm going to hit this one. You have to arrange them.
14:11
Now let's click here. Okay here you can work in perfectly. It's working perfectly. Here
14:18
you can see here simply here it very simple right? I hope you guys you
14:23
understood things well. I will see you in my next video. Thank you. Hi friends welcome to t plus funny channel. In our
14:30
last class, we stopped the stop here to create the user interface. Let me continue the video. So, select the
14:38
uh our package com project view. Here I'm going to create right click new.
14:44
Here I'm going to create this time not the J frame. Instead of that we have create the J panel form here right the J
14:51
panel form. I'm going to give here as a name target
14:57
this a when you click this button this form should be open click okay
15:03
right this form is created now let's expand the form little bit bigger here like this right now here what you're
15:10
going to do is here I'm going to first uh I need a tool bar so I have to get
15:15
the toolbar from the tool pallet so where the tool bar is a tool bar you have drag and drop it here the toolbar
15:22
you have buttons. So you have to drag the buttons as here you can see the but uh here you can read the buttons put the
15:28
buttons right button. Okay, here you right click and edit text you have to write uh whatever new right. So if you
15:37
need another button, click select and put another button. This one data save.
15:45
You have drag and drop another button. This one should be the update. Right. You have to the button. Right now
15:52
after that what you going to do another thing we need to do the another thing is that we have to drag the split panel.
16:00
This one drag and drop it here. Right. We have already deleted this one.
16:06
Right? Now you have to increase the size little bit like this. Right? You have to do it like this. Now here we have this
16:13
is the horizontal view. You have to what you do is it's come completely come to orientation. It's horizontal. You have
16:18
to make this vertical. It's coming this one. Now this view I'm going to drag one panel here. Also drag the panel below as
16:25
well. Select the first one. Here you have the slip view. Here you have divided as your 200. Press enter
16:33
key. Now you can see here this 200 mean here this one here we have little bit you have to you have to bigger right so
16:39
this area I'm going to do the thing is you can see here this area you can you
16:45
can see here you can get this is the if you want to check the design it's look like this right so frame look like this
16:52
here right so here I drag it the uh labels so labels I'm going to drag
16:59
the labels first where's the labels so drag the labels Here this one. This one
17:05
should be our which one is a label target name.
17:12
Target name. Right. Second one should be there. Same
17:17
thing. Ctrl C to copy. Ctrl V to paste. Get another copy. This one should be the target
17:24
amount. This one amount. Let me make this amount. Third one should be C. Copy
17:29
control. This one should be target date.
17:35
Right. Perfect. This how we have make the system. Now we just hold on shift key down and select all. Right click and
17:41
properties. You make the little bit increase the size of the font little bit 24
17:47
or let's increase the size little bit 18 should be. Right. Now here I'm going to drag
17:56
the each text boxes to align align it. The first one,
18:04
right click properties. This one you make it as 14.
18:09
Right. So close it. Right click. Edit text. Backspace to remove the excess. Select again. Ctrl C. Copy. Control V to
18:16
paste below. Control C. Copy. Control V to paste below.
18:25
Perfect. Now what you're going to do is you have did the thing successfully. Now here I'm going to drag the uh
18:33
uh J table. So if you are drag the J table
18:39
you can see the J table is the J table. If you drag it here you can see it's go
18:44
below below the line. You can see it's not fitted the screen. So what you're going to double click on this you can go
18:51
here this frame here. Now you can drag it successfully right now here. Now if you
18:58
drag it now here double click on this sorry here you double click it goes to the your frame it will set up this this
19:06
is the uh beauty of your drag the splitter street plan this how we have make the project beauty okay state plan
19:13
using to uh do the project beauty okay you have to use the split plan right
19:20
okay right now what you're going to do is we have detective success
19:26
now the things Right click table content we have to write the row we have to
19:32
count all the things we have to make it as zero. First out the column first one should be make it as id
19:40
second one should be the target name so you have to make it as name amount
19:48
date you have to make it as a date that's it after that you have to close it now it will be changed right
19:54
successfully done the target part right click on this one target
20:01
uh right perfect it's well Now what you going to do is we have to do the another
20:08
thing is that the target form I just copy it and paste it again. Paste here. This one
20:15
you have a contribution.
20:22
If contribution here also you write first one is the
20:28
north. Second one is the date.
20:36
date amount target amount.
20:44
Third one should be the copy and paste it here. The target ID,
20:52
this one should be the combo box, not a box. You have to make it as a combo box.
20:58
You have to drag it the combo box over here.
21:08
Select this one. Select the model. Delete them. Press
21:15
enter key. After that, you what you're going to see here.
21:36
Right. After what you're going to do is here you have to do the thing is here also you have to change this one table
21:43
content uh columns name first one should be the north
22:04
right make target that's right perfect we done the things
22:11
perfect well right now what we want is we have done the things two things are well let's go to our
22:19
uh main page is a form right a form the main this a main form okay so here what
22:27
you're going to do this is the main form When you click this one, this for uh goes to the target. If you click this
22:33
button, it goes to the contribution. Okay. The first thing what you're going to do is here you have to do the thing
22:39
is here. Uh first thing I'm going to
22:45
uh go to the main form. This is a main form. You click on this. Sorry. And go
22:51
to the source. Source here. You have to go to the
23:01
main window mean the a main form here what you're going to see here I'm going to look at feel of the application as a
23:08
windows progress it's no problem take the windows look and feel right so what you're going to second one I'm going to
23:14
do it here when you click this button it's go to the form so select right click event action action form I would
23:21
set it here as Here I'm going to set it. This goes to
23:28
the which form target. So target form create the object target
23:45
Now here t dot. Now here we have not t you have imported here this one. What's
23:51
the name of this one? You have write a this button one. So here button one this
23:56
one uh right so button one
24:03
instead of button you have to write this one as a slit J slit one pan okay if you click on this one J split pan one so
24:10
here you have to get this name uh this J split one okay so write J split one J
24:17
split uh what is the name Jsplit
24:24
What? So click on this. The same name I have put it here. Dot
24:29
write set right component. You have to
24:35
make it as this T. This T over here. Right. When you click this button, let's
24:47
Click on this darker here. You can see here. This go here. You can see here
24:52
right. So here what you want is let's increase the site a little bit bigger.
25:08
Now let's you can see click on this. Now here it's adjust successfully. Here it's working perfectly. This how the software
25:15
is right. So now again I'm going to this one you click on this. The same thing
25:20
you just copy it. Click on this and paste it here. This one also
25:27
contribution. Contribution
25:34
here also the contribution it goes to the C. Your user update C. I just create
25:40
a C. Now let's check it whether it's working fine or not. Click target. If you go to the
25:46
contribution scores contribution, it's working perfectly well. Right, it's working perfectly well. Uh I hope you
25:53
guys understood things well. Uh I'll see you in my next video next time. Thank you.
26:02
Hi guys, welcome to tutors funny channel. Uh let's continue our WP
26:08
uh project. So here you can see here in our last class we done the UI part. Here
26:15
we have to give the names. Okay, we have to change the name of this uh target text box name. We have to
26:22
change it first as a txt name.
26:27
This one should be have change it as txt amount.
26:34
This one should be txt date. Right now first this is the new button.
26:43
Double click on this this button. What you're going to do is here we have to
26:50
txt name dot set text
26:57
you have write clear. Second one txt amount
27:07
set clear. Third one txt date need to be clear. So we have to clear the
27:15
things whatever you are written right. We got right through the program. You can see
27:28
click target. If you return something else here, you want to clear.
27:33
Click new button here. It's clear, right? Clear. I want to focus on the target name text field. So you have to
27:39
write the same name. I have to put it here. txt name dot
27:47
request focus right now let's run and check
27:59
click on this type something else click new here it's focusing right perfect now
28:05
what you're going to do is I'm going to add the data
28:11
save method data using the op model. So in order to do
28:18
the task we have to first go to the controller. We simply have to go to the controller. Before that you have to add
28:24
the you have to go to the Google and type my SQL connector jar.
28:40
Uh you have to get the jar file
28:48
right. You have to set the jar file. Click on here.
29:01
Second one. Right here. This is ship file. You have download them.
29:08
No tax. I just start my download. You have to the download download download starter. You have to wait until the
29:14
download has been completed to this file. So in order to do the thing is
29:19
first you have to go to this is your project. Okay, this is a project
29:24
uh you have to build the project. You go to there uh your project ask your
29:30
projects created the directory. Okay here your project is created. So we just copy this path it go here
29:39
paste on here which is your project my project is
29:44
sales t you go here here I'm going to create the one file right which is a I'm going to create lib
29:53
that is a li here inside the lib folder I'm going to
29:58
pass it that connector right so uh when
30:04
when you cut this your project and bring to the bring into another machine
30:10
that driver is not affected so that you have to pass it here.
30:15
So you go here you can this is downloaded I just extract them
30:31
So MySQL J here you can see the MySQL J
30:37
just copy it this one. this one
30:43
to paste it here inside the lip folder. Right. Okay. Right. Perfect. Now what
30:48
you going to do is here after that you have to go to the lip folder. The libraries you have to add it here. So
30:55
you just add your folder.
31:01
You have to select that from your project. So our project is
31:06
uh for here this project you have to just copy this path we have to given the path
31:15
C drive the C drive C drive it's located the C
31:34
documents net piece. documents
31:40
net beans project here I'm going to target uh here this one sales target
31:46
inside the folder here's a li folder we have a my right we have to
31:53
attach like this so here it's building so this we have to attach this efficient way to do it right this is must right
32:01
okay that's we are doing it right Perfect. Right now here your file is there.
32:08
Right. So it's perfect things you have to do it. Right. Now what you're going to do is
32:14
after that I'm going to go to the controller file. This a controller. This controller I'm going to make it as a
32:21
class which is a target controller.
32:34
This controller class we have to make this method which is static public
32:51
save right. So it pass the arguments string
32:56
name what are the fields are there? name, amount and address. Uh amount and date.
33:04
Okay. So here we have implemented name. This argument
33:09
you have write string amount. We are not doing anything else. We just make it a string string date.
33:19
All right. So here we have open and close bracket. So we have to write it here is first you have to string
33:41
colon local host you have given the port
33:57
MySQL work you can see this a port you have to write the port it will be running
34:03
32 six this a port it will be running you have to open it here this port it will
34:11
be running so I get a port over here uh the database name this is database
34:16
name you have created database name which is IFC this one here you can see the target you have to open up this is
34:23
your tables right it's a target so if
34:28
right so I have write here IFC
34:36
right simple stuff you have to write after that you have to write the string
34:43
your username the username username name equal
34:52
is a root while installing a MySQL work I gave the username as root string
35:00
password you're right password equal your right group 1 2 3 is my password
35:06
right that's it that's right use the username and password is right
35:30
Sorry right now what I'm going to after that you
35:36
have to write the register the driver so you have write a register driver you are using class dot
35:44
for name first you have to write You have to write com
35:49
dot MySQL dot write CJ dot
35:58
uh CJ do MySQL CJ JDBC
36:03
dot driver you have to register the new way driver lights right so it's not it
36:10
ask import the try and catch block some try and catch block this error go away you can see here After that what you
36:16
have going is you have to write a connection. So you write a connection obvious connection
36:23
that is conal driver manager
36:29
to make the connection you write the uh connection class. So you write here
36:59
the SQL package over here right import java.sql
37:06
right after that you have to write driver manager
37:18
manager dot get connection
37:33
comma pass p that's it that's the thing you have to write it after that what I'm going to do
37:39
is here we have to add another catch block as well this one implemented
37:46
Now you're going to use the prepare statement. You have to write prepare statement. You have to create a
37:52
prepare statement object. So to write prepare statement
38:07
conduct prepare statement. So you have to write
38:13
this SQL. You have to write the
38:18
you have to write the you have to check the SQL course over here. Right? You have to check the SQL course. Right? So
38:25
you have to write it here. Uh you have to write it here. You have to write insert into
38:34
insert into which you going to add it target table. Here the t the table which
38:40
name is target. So target
38:45
this is the columns name amount and date.
38:52
So you write into target
39:00
you have to the name comma
39:05
amount and and date only
39:12
right after that values
39:19
values you have to write three question marks as a parameter.
39:25
That's it. That's the thing you have to write it over here. But here you have to implement the
39:31
prepare statement. Uh prepared statement
39:46
statement. Right. Perfect. Right. That's the thing you have to write it. Now we have set itst
39:59
So string you have type one mean name write one name for the name you are
40:04
coming here name here parameters second one should be
40:10
there two mean amount
40:16
three mean you have set as a date
40:23
right simple stuff you have to write it after that you have to write tst
40:33
nonquy. We ask the nonquy. Execute non execute
40:39
nonquy. So we ask to execute sorry execute update.
40:46
Execute update this one. That's it. That's the thing you have writed.
40:52
Right. After that you have write a return
40:58
to right return to is there any problem
41:27
right? That's the thing. You have to write it
41:37
right return. Okay, that's the thing we have to write
41:44
it. Right. Right. I hope you guys understood
41:51
the things well. In my next video tutorial, I'm going to teach about the
41:56
this class and how to save the data. Right. Thank you for watching.
42:02
Hi friends, welcome to Tutsp. In our last class, we saw the controller
42:07
section of the programming. Now here I'm going to go to my uh target Java. Okay,
42:15
the save function button. You go to the save button. First I have
42:20
to set the values. So here this one target name, amount and date. So you
42:27
have to first you have to create a variable string. Uh this one should be date.
42:36
Sorry. Name target name. Target
42:54
I'll just copy this here. This one should be the txt amount.
43:02
This one should be amount.
43:10
date string date. This one should the date
43:17
right now here. Now here we have to create the variable boolean data type
43:25
have to create as save equal
43:31
to call the target controller
43:37
this target controller you just right click this one copy this
43:46
dot Save. Uh do that. What are the functions
44:19
Right. Save this method. Save method. So here
44:26
we have to write it here as here target. So we have to write it here.
44:32
This one com program target controller. It has a method which is a save. Just
44:37
save method. Here you have a what is the uh it's giving response is the name
44:45
the target name amount date we have to give it here
44:52
right you have to give it here this one should be boolean right so you have to give the type right
45:08
it Messages display J option
45:20
dialog look like this. Save
45:43
Right now let's check whether it's working fine or not.
45:54
Target you have to write ABC amount this
46:01
date is this you have to write for start with the year 2033
46:08
month 12 month three hit save button
46:15
here save it's working here it's working saved successfully it's working okay now
46:21
let's uh close it. Now let's check uh in the
46:27
database whether it's working fine or not. My work back
46:47
and see here table target here it's saved successfully right it's saved
46:54
successfully now what you're going to do is I'm going to go to here it's working successfully
46:59
Now after save the record we have to clear the field. So yeah we have to rotate all things. We have to focus on
47:05
here this one. Paste it over here.
47:13
How to save. Right. Perfect. Right. Now what you're going to do is
47:20
instead of the things we have to implement the antilation so into our project. So here we have to in order to
47:27
implementation the encapsulation part you have to go to the model section you have to make the class target.
47:35
So this is the efficient way to implement the WP right here. You have to
47:41
create a variable string name. So target name you have to use a
47:53
uh double amount. So
48:02
this is a date look like a straight date. G now here now I'm going to implement
48:10
the this a model class in model you have to implement the right click refactor
48:16
you have to implement the encapsulation fields I need all the fields
48:21
you have to select all right okay so you have to select all you
48:26
have to click on this defect it to implemented that all of it should
48:33
be very simply Okay, you have to implement the encapsulation, right? So this how we have to do the
48:39
programming, right? Okay, so now go to the controller. Now you can see
48:46
here only the three datas here name, amount and date. So if you imagine if
48:52
you have a more than 10 fields of the of the of the
48:59
form form more than 10 fields here only three fields of more
49:05
than 10 fields. So each and every field you have to put uh we have to write it here string date string address all
49:12
thing instead of that if you are writing like this it is very
49:17
efficient way to write the book right I do it like uh like this way so now here
49:24
the same method what you're going to call it here is target
49:29
this class target this class target the object target
49:39
this one we have to get it the import the package it's a model package you import the model package now here it's
49:46
not error we have to get a get method so you have to write get name so write a target this target
49:59
dot get name out of that Target
50:15
Okay. This one should be there. You have to set as double that we have to make it as a double.
50:29
set date. Get date. Right. That's the thing you have to we have to get the all the
50:35
data. Right? So we have to get the data from where the model you have to get the data from the model and pass into the
50:42
controller. Right? So after that controller pass into the view. So view over here
50:52
same method here you have after we change it it passing the error.
50:59
Okay. It will be passing the error. So here what you're going to do all here is we have to remove it.
51:07
Okay. Have to remove it. So here you have to getting the data like this.
51:14
Back here right here also.
51:19
Now let's go to the target view here. This one we have to make it
51:25
as little bit confusing. We have a same thing in target here also. Target you
51:31
have to change them simply refactor rename target model make as target model
51:40
make as target model is target model also will be change here also you have
51:46
to go to here I first implemented the target
51:53
model create the object d equal new target model.
52:04
First T dot here you have to implement the target
52:10
model. Right? After T dot you have to write set
52:17
name. You have set this target name over here. After that t dot
52:24
set amount you have to type this amount over here
52:34
that amount you have to write it here double pass double dot
52:39
uh double pass double
52:44
because I'm put it as a double so we have to write double
52:59
Now that we have t you have to write here
53:12
right or we are calling this t here
53:18
to add the data right first you have to get the data here first you have to we
53:23
have to get the data for the data receiving after that all the data we have to set
53:29
it to set into the t the data for the data you're typing you
53:34
are setting to update uh at the data let's check whether it's going or not
53:40
target name B uh your target name you have write uh
54:00
I just type it. You have to write the target amount. I'm going to write this
54:12
12 date five. Click save button. record
54:19
save. Right now the object oriented concept is working fine. Right now if you want to check it
54:43
Yeah, it's working successfully. Perfect. I'll see you in my next video. Thanks for watching.
54:50
Hi friends, welcome to T fun channel. In our last class, we saw how to add the records into the database using the
54:57
double OP. In this video, I'm going to teach how to view the records. So first what you're going to do is here I'm
55:04
going to go to first I'm going to here I'm going to configure the database
55:11
connection here. So first this connection we have to maintain with the
55:17
separate file that is the efficient way to do the program. So how to maintain
55:22
with the separate file? You can see here that I have a separate package which called as DB. Here I'm going to create
55:28
the class new Java class which name is DB.
55:35
this class. What you going to do is you have to create the public
55:50
equal null. After that we have to create the
55:57
function which is a implement the name space. Here we have
56:03
write about imports import java dot
56:09
sql java uh we have to implement this
56:15
package java over here
56:21
java connection get connection method
56:28
but you have to write the throw a throw throw close
56:34
using the exception handling open and close bracket. Here you have
56:40
write if connection equal equal null. The connection is null
56:48
you have to create the connection. So we have to create the connection here. This connection you have created.
56:56
Cut off here. Paste it here. So the connection is null. You have to create the connection. Okay. If the connection
57:03
is null, you have to create the connection right. So you have to implement the
57:08
second thing is a dissolve things. But implement the connection,
57:15
right? You have to write like this, right? You have to write like you have to
57:20
create a connection, right? So if the connection is already there, you have to return the connection. Here we have return
57:32
The connection is already there. We have to return the connection. So very simply we have to do the things. Okay. Separate
57:37
by the file. What the meaning of is if the connection is null mean if you don't have any connection you have to create
57:43
the connection. So when you run the program if the connection is already there it will be
57:49
return the connection. That is the things we have right over here. You have to understand this line what what
57:56
happened the null things. There are many students not aware about these things.
58:01
Well, okay. Why we have put null here? The connection is null. Nothing. There's no connection. You have to create the
58:08
connection first. If the connection already exist, it will returning the
58:14
connection. Right? That's the thing we have to do it. Right? Perfect. We done the perfect things. Right? Now, let's back to my project. You have to
58:20
implement this, right? You have to implement this connection to our project, right? So, how to implement
58:26
that? Uh we have to implement this
58:33
right now. You have to try to implement the connection. You have to write a connection
58:45
equal DB. This is named DB dot
58:52
DP dot write DB. You have to write the import
58:58
library here. DB dot get connection. You have the get
59:09
you have to get the get connection. Get connection. What you have to throw the catch
59:17
that's the thing exception right so you have the exception you have right that's the thing we have to write okay now that
59:24
thing is working qu that we have write the view code so view how to write it
59:29
here is uh we have write the view part
59:41
now I'm going to view the data Now you have to create the list. So you have to write public static
59:48
list. Here you have write target
1:00:02
type list get all we have list it's it is a class it automatically important. If the card is not there you click on
1:00:08
here here you have click on import the YouTube package right okay that's the
1:00:14
thing you have to write it so here after that you have write a list list target
1:00:21
you have create the object list equal new array list you write array list
1:00:31
array now what you have import class has been looked in array list.
1:00:38
Right? Now here what you going to do is you have to write this you have to create a query string SQL
1:00:46
equal select all from target
1:00:59
right after we have to establish a connection. this connection
1:01:09
past it below right. Here we have to this one add it
1:01:16
over here. This one you have created one for the basic right. So here right
1:01:24
variable myster object in this one resol set
1:01:35
RS equal tsta statement object execute par
1:01:52
Next. Open and close curly bracket till you write target
1:02:16
So write RS dot get
1:02:33
after that the same thing just copy paste it below
1:02:39
here I use one mistake not a target the model we have the target model that's
1:02:45
the problem. You have to make it here as a target model. That's why it's a
1:02:50
problem is error is
1:02:57
the target model right now. Here's the target model. The target model target
1:03:03
now here you can see set here set name
1:03:08
is coming. Okay, here set name is coming. It's perfect. Now here it's working. Perfect. That's the problem. I
1:03:15
called the wrong class. That's why it won't work before. Now we have RS dot
1:03:27
we have write name. How that
1:03:34
this should be ammo
1:03:55
Keep double. After
1:04:00
that third one should be set date.
1:04:06
Set date. This one should be the string date.
1:04:26
right here? set date
1:04:38
change as a date that's the thing you have to write after that you have to write you have to add
1:04:44
all things to the list so you write list dot
1:04:57
after that we have to return
1:05:09
right that's the thing you have to write in our next video I'll be explaining the
1:05:15
rest of the things thank you for watching hi welcome to it funny channel in our
1:05:21
last class we saw how to view the records So we have completed the list. So here the list we have to get the
1:05:29
data. We have to load the data from the database. Get the data using the set method. We have set it and passing to
1:05:35
the our J table. So we have to pass into the J
1:05:41
table. So how to pass into the J table? We see right. We have to pass into the J
1:05:46
table. We'll see. Right. So here this our target
1:05:53
uh name ID name date anything is a uh
1:06:02
let's go to the database my SQL workbatch
1:06:32
This our table complete and you have to one more column
1:06:39
you have to add it as a complete. So you have to write right click table
1:06:46
content columns you have to write another column complete
1:06:55
right perfect right now perfect now let's go to the
1:07:01
source I'm going to first you have to declaring the first you have to create the method which is a public
1:07:11
wide But public wide
1:07:33
You have to write default
1:07:57
equ= new. You have to write this one. You got to
1:08:03
make it here. You have to cast it.
1:08:11
You have to add the class. Import this one. Okay. You have to write the table which
1:08:17
name is J table one. Copy this.
1:08:24
Ctrl C. Copy this. Back to the source. You have to paste it.
1:08:46
that's it okay what the error here it's asking all right return it's no problem
1:09:07
But after that what I'm going to do is here we have to write this n dot
1:09:13
set row set row count
1:09:25
default table model.
1:09:33
Right? So after that we have to write a list list.
1:09:48
This one you have made us list.
1:10:07
Now you have to write it here. Open and close bracket. You have to write here TM
1:10:12
dot get ID comma TM dot get name
1:10:21
comma TM dot get amount comma
1:10:37
uh get amount uh get date
1:10:44
right so you have to pass a get date tm dot get complete
1:10:52
uh here write on is complete it's not get complete it's
1:10:58
complete I think is complete correct that's the thing you have to write it so
1:11:03
we have to write like this so after that we have put colon
1:11:09
after that we have Uh we have to call it to this object m
1:11:23
this row that's the thing we have to write it. So that's thing we have to write it. Uh now
1:11:31
let's check it whether it's working fine or not. This one this load method you just copy it paste inside here.
1:11:42
paste inside here. Now let's
1:12:17
get the connection is null. Which connection is null?
1:12:28
Right. The problem is a database connection. You have to make it as a you have to change it as a public also
1:12:35
private. You just change it as you earier you write public static uh
1:12:41
connection you have write static it it automatically take as a driver this all things right after that you have write
1:12:48
the same thing connection object your driver you have to write the driver over here this driver also you have to call
1:12:54
it here okay that's a problem the driver separately you have to write the class and call it here the same thing you have
1:13:00
to return the connection right that's the thing uh the error will be displayed now here now if you have open the
1:13:05
program and your target. Okay, it's working properly, right? The simple stuff, right? So, the ID is why is not
1:13:12
working uh look at the database is working ID
1:13:25
right? ID. Why it's not working? Go to target ID.
1:13:33
Here's a model. So model also we have return
1:14:07
the problem is here. This is not a get set name. It's a get. This is not a game here. It's a problem is here. Set tid.
1:14:14
Right. That's a problem. Okay. Now is it's here. Get as get in. That was a
1:14:20
problem. Okay. First you have to understand right here. First you have to understand
1:14:26
when the problem is come. There are many students are not understanding here. Now it's working properly. Fine. First if
1:14:31
you get any error you just read the error and you can get the solution. Some other students are not reading. Right?
1:14:36
So this how we have complete the project. So we have to do the update and delete but all search but all the things
1:14:43
we have to later on. Thank you for watching.
1:14:48
Hi friends welcome to tutors funny channel. Today I'm going to teach the search box. Okay. Here you have a search
1:14:54
button. We have click on this. It ask ID. If you type the relevant ID uh target ID the relevant details should be
1:15:01
display over here. But let me see how to do the task. Right now let's we add one button. The one button we have drag and
1:15:09
drop it that drop that button I have to name it as search
1:15:17
right this button what you're going to do is we have to uh go to our controller
1:15:26
you have to I'm going to create a one
1:15:31
method static method just search so I write the same thing public static
1:15:37
static. This is static method. Uh we have a target
1:15:44
target. We have a target. We have a get id get ID
1:15:52
in id open bracket and close bracket. Here what you going to target ID. You have to
1:15:58
ask the target ID or a target model. It's a target not target. Target target model. This one target model here.
1:16:07
Okay, here it's coming data is coming from the models. So you have to put it the models here. After that you have to
1:16:13
write the uh target model. Create the object T equal new target
1:16:20
model. New target model.
1:16:28
After that you have to write string SQL equal select
1:16:35
all from the target
1:16:44
target where id equal question mark.
1:16:53
After that you have the uh this connection object
1:16:59
and prepare statement object and also this both are copy and paste it over here. Uh here you have to write it here.
1:17:06
It ask the try and catch block. You have to ask the try and catch block
1:17:11
cut off and paste it over here. After that what I'm trying to here RS
1:17:18
we have RS2 right. Okay. So you have to search
1:17:24
search the record. So prepare statement you have search the record. So what you're going to see search I'm going to
1:17:29
write prepare statement of the PST PS
1:17:34
dot set in set intrid.
1:17:42
What's the ID you are typing on the text box is taken uh match the uh record will
1:17:48
be loaded match with the ID. After that you have to write the second step is here you have to call this one. So just
1:17:55
copy and paste it over here you have write here if RS2 this one next right
1:18:02
here you have to load the data. So how to load the data here? We have to get them. Uh we don't need this one.
1:18:10
We don't need them. We have to get this one. Whereas this
1:18:17
t dot set ID is RS2 is also RS2.
1:18:26
Right? So that's the thing you have to do it right. You have to get all the details. So you have to write here you
1:18:32
have to write E dot Print trace X dot. Trace
1:18:41
print trace. If they get any error or return
1:18:52
T right so you can see here when you type
1:18:59
the ID is coming to the parameter here. It search the error search the record what's the target ID you are typing here
1:19:06
uh this parameter it's searching the ID and match with the record it will load it and here RS2 it will get the match
1:19:13
result and passing to the m set the matching result in the relevant field over here now we have to go to the view
1:19:20
we have to get them right we have to get them right so here we have to get the
1:19:26
when you click the ID the m the result will be display over So what you going to do is you double
1:19:32
click on this search button. So here we have to write the code right. So here we
1:19:37
have to write the simple you have to write it uh write
1:19:45
string id. string ID.
1:19:51
You have to write a J option pan. G option pan
1:19:56
dot show show message dialog.
1:20:02
How to write uh this note right here.
1:20:32
Sorry, the problem is not this. Write here. Show message not message. So here
1:20:41
show input dialect. Show input d. This is the right. That's why
1:20:47
after that we have a target model this target model
1:20:56
T equal we have to add different name T2 equal
1:21:01
target controller this target controller target
1:21:06
controller dot get ID what the it's not Target
1:21:15
target here dot get ID what's ID IP get ID so get ID
1:21:23
ID but error because we have to convert as integer so integer
1:21:29
dot pass ID that's it simple stuff simple write
1:21:37
like this simple you have like after that what you're going to do
1:21:49
you have to set the ID. Right? First you have to set the id. You
1:21:54
have to write uh int set id
1:22:01
uh you have to write syn id equal
1:22:11
write like this. Get the ID here. We write like this. Simply
1:22:17
txt name. This a text name dot set text
1:22:27
set text target name. T2 dot name TD do.name dot
1:22:34
get name. Copy and paste it.
1:22:41
This one txt amount
1:23:13
So we have tried here a string string dot value of
1:23:51
So write all things are set. The ID also we have write this ID. Uh we have write
1:23:57
it here. We don't need the ID. So we have it like this. Uh that's the thing I
1:24:02
have. Now let's check it whether it's working fine or not.
1:24:11
target. Click it working one. Okay. Here
1:24:18
respected record will be displayed. If it is two here,
1:24:23
if it is three, now it's working fine. So it's working fine. Okay. So very
1:24:29
simple. So what I did here is here when you enter the id when you enter the id
1:24:35
passing to target model so it tested. So here we have to test it
1:24:40
to the controller controller td. So what happen is it goes to the controller class get ID method. So get ID method it
1:24:48
receive the ID here. So here it will be search via the
1:24:54
model to the database. uh what the ID matching value will be if the id exist
1:24:59
it will be matching record will be it will be setting like this right after that it
1:25:05
will return to here this way that's the thing we have done
1:25:12
right I hope you guys you understand things well if you have doubt you can ask me anytime if you love my channel
1:25:17
please subscribe me like me thank you for watching hi welcome to tutors funny channel in
1:25:24
our last video we saw search uh search part in this video I'm going to talk about the update part so what you going
1:25:30
to do is go yeah I have to forget one thing you have write get this ID as well
1:25:35
string id equal string dot value of
1:25:42
you have to write the t2 dot
1:25:47
get you get the id you have tested whether
1:25:56
ID one already exist this I have put it there. So here we have tested system out
1:26:06
print whether the ID is coming successfully or not. You have to do it like this.
1:26:20
ID one. Sorry. Now let's
1:26:26
if you have search here one sorry search one match record will be display here. The
1:26:33
console will be printed. If you have the two it will be printed successfully. Now the ID is displayed successfully. Now
1:26:39
what you going to do is I'm going to go to this. If you click on the records table records the selectable row will be
1:26:46
displayed to here. So if you have selected here target select this one the selectable
1:26:51
record will be passing the form for update. So what you going to do is you have select this table right click event
1:26:59
mouse click. You have to select this one. Here we have to the mouse click. We
1:27:05
have to write the simple code. We have to write int row equal this table name.
1:27:12
This a table name. Uh this table. Copy this. Paste it over
1:27:18
here. Dot get selected row.
1:27:28
Get selected row. If row
1:27:34
not = 1. So row is not equal 1. Okay. So
1:27:39
the row right not= 1. What you're going to do is we
1:27:47
have to pass it this one. That's a search.
1:27:54
After that you have to write the string variable. string ID equal
1:28:00
get table on this one dot
1:28:06
get value at row zero
1:28:19
after that you have write this all this these all the things you have just copy paste it
1:28:25
So what's the ID you are getting? You're clicking. We have to get that particular ID. This ID we have to pass it here and
1:28:32
we have to load that. That's the thing you have to write it here. So if I click on this application here it's passing
1:28:42
okay it will be changing here
1:28:48
it will be changing here okay it will be changing the matching
1:28:55
row right so for edit the records so that's the thing I have written over here very
1:29:02
simple right editable record will be what the row we are select it will be passing right so stable mouse
1:29:10
click right so you have to pass in that particular that's the thing you have to
1:29:15
write it over here now I'm going to do the update part so
1:29:21
go to the controller target controller here we have to go to the
1:29:27
here we have to go to the public static
1:29:47
open and close back. So here what you're going to do is save
1:29:52
edit code to save code. Copy this
1:30:03
here. You have to write insert. Instead of insert we have to write it here.
1:30:09
Update. So write update
1:30:14
target table. Target set name equal question mark comma
1:30:23
uh target name amount question mark
1:30:31
comma date equal question where the ID
1:30:37
id equal question we have pass the parameter right the same parameter to pass it over here that's been right. So
1:30:44
what you're going to do is here now what I'm going to do is uh
1:30:57
what is target model target what you do is here as well a target
1:31:06
model target here we have to write here as a target
1:31:11
that's right Now to what I'm going to get we have to do another thing you have to get the ID
1:31:18
also you have to set in
1:31:24
this ID is a score change score to here the id get ID
1:31:32
okay so when you update the record you have to pass the if you change the name and amount and date where the id is
1:31:38
coming it will be update the record uh based on the ID right So what you are
1:31:43
going to rest that's the thing you have to do. Now let's back my target here the
1:31:49
update button you have to write the code. So here
1:31:56
here you have to write the same code you just copy it. Paste it over here.
1:32:03
Right. The same code you have to paste it over here. Now we have to write it.
1:32:09
Now here this one we have to make it as a target update. This one update. Now
1:32:15
here when you update record so we have to pass the id. So how to pass id here you can see the table when you click
1:32:23
here is ID you passing here we have to create this one. You have defined this
1:32:28
variable inside this table. Here we have to copy and paste it over here. You have
1:32:34
to make this one as a common one. You make it as integer type. This one you have to get rid of this. Here we have
1:32:41
integer type. We no need to convert. We have to get rid of this one. Right now here this one we have to implement it
1:32:48
over here. So how to get it? D dot set ID
1:32:53
ID here. It's integer type. So that we have to get the integer. Right. That's the thing. Now let's this one should be
1:32:59
the update out of the file. So let me check.
1:33:07
Click on this. I want to update this code. Click on this. I'm going to
1:33:12
target. We have to target code
1:33:20
target name amount. This say amount this a date, right? So target date, right? So
1:33:27
update record updated. Now let me check it again.
1:33:33
It's working here. It's working successfully. It's working right. So we have to it's working successfully right
1:33:39
no problem it's working successfully right I hope you guys will understood the things well in my next video
1:33:44
tutorial I'll be teach you the uh delete part thank you for watching