Вы находитесь на странице: 1из 32

DATABASE

CONNECTIVITY java
HTML MYSQL
Informatics
Practices Record
File
Meerut Public School or !irl"
CODE # $%&
Sub'ite( To)
Sub'itte( B*)
Mr"+ Shali,i Shar'a Shri*a
-ai,
.II # C
HTML '*"/l -AVA ht'l
DATABASE
CONNECTIVITY java HTML
MYSQL
JAVA GUI
PROGRAMING
Ques. 1. Calculate Commission For !e "ales Man. !e Commission Is
Calculated Accordin# o !e Follo$in# Rates.
%Create a GUI A&&lication As Per !e Follo$in# "creen"!ot.
%'&e t!e Follo$in# Code (' )ou(le Clic*in# t!e CA+CU+A, COMMI""ION
-utton -elo$ t!e "a's.
00Obtai, i,1ut
Stri,2 t3t4Sale"t5+2etTe3t678
(ouble "ale"9co''+8
"ale"4Double+1ar"eDouble6t3t78
00Calculate co''i""io,
l56"ale":;$$$$7
6Co''+4"ale"<$+=&8
el"e
l56"ale":>>$$$7
Co''++4"ale"<$+=$8 el"e
l56"ale":=>$$$ Co''++4"ale"<$+$?8 el"e
l56"ale":&$$$7
Co''+"ale"<$+$;8 el"e
Co''++O8
00obtai, out1ut
Co''lbl+"etTe3t6@THE Co''i""io, i" AS+@Bco''+78
Ques./. 0rite Code to translate to its e1ui2alent name of t!e da' of t!e $ee*.
"olution.
00a""u'i,2 (a* ,u'ber i" available i, i,t variable (oC+
SCitch (oC
D
a,"4 Su,(a* 8
breaE8
a,"4@Mo,(a*@8
breaE8
a,"4@Tue"(a*@8
breaE8
a,"4@Fe(,e"(a*@8
breaE8
a,"4@Thur"(a*@8
breaE8
a,"4@ri(a*@8
breaE8
a,"4@Satur(a*@8
breaE8
(e5ault)a,"4@Fro,2 (a* ,u'ber@8
G
Out1ut+"etTe3t6@FeeE Da* 5or (a* ,o+HH i")I Ba,"78
Out1ut)
FeeE (a* 5or (a* ,o+% i")ri(a*
FeeE (a* 5or (a* ,o+== i")Fro,2 (a* ,u'ber
Ques.3. 0rite a Ja2a Pro#ram to Find out $!et!er a 'ear 456di#it no.stored in
2aria(le 'ear7 is a lea& 'ear.
"olution.
I5 6*earJ=$$44$7
Di5 6*earJK$$44$7
S*"te'+out+1ri,tl,6*earB@i" a ce,tur* *ear a,( a lea1 *ear@ 78
el"e
S*"tL'M+out+1ri,tl,6*earB@ i" a ce,tur* *ear but ,ot a lea1 *ear@78
el"e i5 6*earJK44$7
S*"te'+out+1ri,tl,6*earB@i" a lea1 *ear@78
el"e
S*"te'+out+1ri,tl,6*earB@i" ,ot a lea1 *ear@78
Ques..5. Gi2en a GUI A&&lication !a2in# a la'out as s!o$n (elo$6
!e a&&lication intends to &rint# n odd no8s and !as t!e follo$in# code in t!e
action e2ent !andler of its &rtnt (utton.
"olution.
Stri,2 val4i'1t5+2etTe3t678
i,t ,4l,te2er+1ar"el,t6val78
i,t i4=8
5or6i4=8lN,8iB4>7
DStri,2 t3t4re"lbl+2etTe3t678
re"ibl+"etTe3t6t3tB@ @Bi78
Note ) The 1roble' i, the a11licatio, i" ,ot 1ri,ti,2 , o(( ,u'ber rather it i" 1ri,ti,2
o(( ,oM"+ O1 to ,+ To 'aEe it CorE i, (e"ire( 'a,,er Ce have to 'aEe cha,2e" a"
beloC#
5or 6i,t c4l8cN4,8iB4>9cBB7
D
Stri,2 t3t 4re"lbl+2etTe3t678
Ae"lbl+"etTe3t6t3tBI Pi78
G
Ques..9. "c!ools from 2arious cities in India !a2e decided to form a net$or*
is named as Indic"c!oolNet. A&art form connectin# teac!ers and ot!er
officials of different sc!ools across t!e countr'. "tudent can also (enefit from
t!is net$or*. One suc! features a2aila(le: for student s is t!at $it! 'our
friends $!erein a student can c!at $it! ot!er students $!o are currentl'
lo##ed in t!e net$or*.
)esi#n a C!at lo#in $indo$ !a2in# $indo$ Interface similar to one s!o$n
(elo$. Add Functionalit' to it to ma*e it $or*.
"olution.
The te3t5iel( o5 the (e"i2, !OI i" ,a'e( a ci(t59 co'bo bo3 a" cit*cb9 it co,tai,"
variou" cit* ,a'e"9 butto, a" lo2i,bt, a,( label beloC a" Celclbl+
Stri,2 ,'4ci(t5+2etTe3t678
Stri,2 ct46Stri,27(t*cb+2etSelecte(lte'678
Felclbl+"etTe3t6@Nht'l:Hi@B,'B@9Felco'e to
i,(icSchoolNetNbr:HoCM" the Chether at @Bct78
Ques..;.. In t!e #i2en a&&lication $!ene2er a c!aracter is t'&ed in t!e te<t
field 4src!tf7: t!e corres&ondin# c!aracter is .!i#!li#!ted if it is &resent in t!e
list (o< $!en select in list (utton is clic*ed. 0rite t!e code for t!e #i2en
a&&lication..
"olution.
Private voi(
"elbt,Actio,Per5or'e(6java+aCt+eve,t+Actio,Eve,tevt7
00TO DO a(( *our ha,(li,2 co(e here)
Charli"t+"etSelecte(value6"rcht5+2etTe3t6 79true78
Ques..=.. +et t!ere (e a form $it! a lar#e no. of inde&endent te<t (o<es and
corres&ondin# la(els. 0!ene2er t!e c!ec* (o<es 4t!eme o*7 is clic*ed t!e
(ac*#round colour of all t!e la(els as $ell as t!at of t!e te<t field c!an#es to
(lue.. Also: t!e colour of t!e te<t c!an#es to $!ite in la(els. 0rite t!e
corres&ondin# code to ac!ie2e t!is t!eme c!an#e..
"olution.
Private voi( The'e Actio, Per5or'e(6java+aCt+Actio,Eve,taCt7
D
00TO DO a(( ha,(li,2 co(e here)
a((rt5+"etBacE2rou,(6colour+BLOE78
cla""t5+"etBacE2rou,(6colour+BLOE78
5,a'et5+"etBacE2rou,(6colour+BLOE78
',a'et5+"etBacE2rou,(6colour+BLOE78
,a'et5+"etBacE2rou,(6colouc#BtOE78
telet5+"etBacE2rou,(6colour+BLOE78
jlabel ==+"etBacE2rou,( 6colour+BLOE78
jlabel =>+"etBacE2rou,( 6colour+BLOE78
jlabel =;+"etBacE2rou,( 6colour+BLOE78
jlabel =K+"etBacE2rou,( 6colour+BLOE78
jlabel =&+"etBacE2rou,( 6colour+BLOE78
jlabel =%+"etBacE2rou,( 6colour+BLOE78
jlabel ==+"etBacE2rou,( 6colour+FHITE78
jlabel =>+"etBacE2rou,( 6colour+FHITE78
jlabel =;+"etBacE2rou,( 6colour+FHITE78
jlabel =K+"etBacE2rou,( 6colour+FHITE78
jlabel =&+"etBacE2rou,( 6colour+FHITE78
jlabel =%+"etBacE2rou,( 6colour+FHITE78
G
Ques..>. !e #i2en form calculates t!e GC)4?CF7of t$o no8s..0rite code for
t!e command (utton 4cmd(tn7 to &rint t!e GC) in t!e la(el 4I(l#cd7...
"olution.
Private voi( c'(bt, Actio, Per5or'e(
6java+aCt+eve,t+Actio,Eve,t evt7
D
I,t , l4l,te2er+1ar"el,t6,u' lt5+2etTe3t6 7+toStri,26778
I,t , >4l,te2er+1ar"el,t6,u' > t5+2etTe3t6 7+toStri,26 778
I,t t8
Fhile6,>Q4$7
G
t4,>8
,>4,=Jt8
,=4t8
G
lbl2c(+"etTe3t6@@ B ,=78
G
Ques..@.. 0rite a class met!od t!at recei2es a da' no. and returns da' of t!e
$ee*.
"olution.
Stri,2 Da* o5 FeeE 6i,t (a*7
D
Stri,2 (oC4@ @8
SCitch 6ch7
D
DoC4@ Su,(a*@
breaE8
(oC4@Mo,(a*@
breaE8
(oC4@Tue"(a*@
breaE8
(oC4@ Fe(,e"(a*@
breaE8
(oC4@Thru"(a*@
breaE8
(oC4@ri(a*@
breaE8
(oC4MHSatur(a*@
breaE8
(oC4@l,vali( Da* Nu'ber@8
breaE8
G
retur, (oC8
G
Ques..1A.. 0!at $ill (e t!e out&ut if e<ecutes (e#ins from main 4 7B
"olution.
CLASS MAIN 6 78
D
CALCOLATE 6 78
S*"te'9 out+ 1ri,tl,6@co,"tructor@78 G
Voi( calculate 6 7
G
ShoC6 78
S*"te'9 out+ 1ri,tl,6@calculati,2@78
G
Voi( "hoC6 7
D
S*"te'+out+1ri,tl,6@l a' Di"1la*i,2@78
G
Public Static voi(" 'ai, 6Stri,2 ar2"R S7
D
MAIN o,e4,eC MAIN 6 78
G
G
Out1ut)
I a' (i"1la*i,2 calculatio, co,"tructor+++
Ques.. 11.. )esi#n an a&&lication for a foot(all matc! score(oard. ,ac! team
score s!ould (e maintained. 0!ene2er a team scores a #oal: it s!ould (e
reflected on a screen (oard.. 0!en t!e score(oard: t!e $innin# team s!ould
(e declared..
1. )esi#n t!e follo$in# interface in Net(eans I),.
/. "ee t!e names of control.
3. Add t!e follo$in# code in t!e action e2ent !andlers of res&ecti2e &us!
(uttons.
"olution.
!oal o5 A Actio, Per5or'e( 'etho()
Stri,2 v =4ta2oal"+2etTe3t6 78
i,t 2a4l,te2er+1ar"el,t6v =78
2a#2aB=8
ta2oal"+"etTe3t6@ @B2a78
!oal o5 B Actio, Per5or'e( 'etho( )
Stri,2 v =4tb2oal"+2etTe3t6 78
I,t 2b4l,te2er91ar"el,t6v >78
2b42bBl
tb42oal"9"etTe3t6@ MB2b78
(eclare" Actio, Per5or'e( 'etho()
Stri,2 v l4ta2oal"+2etTe3t6 7
I,t 2a 4l,te2er+1ar"el,t6v =78
Stri,2 v >4tb+2oal"+2etTe3t6 78
I,t 2b4l,te2er+1ar"el,t6v >78
Ques..1/.. In&ut t$o no.8s and #et out&ut and dis&la' t!eir sum usin#
functions.
"olution.
i,t "u'6i,t a9i,t b7
D
i,t c4aBb8
G
voi( "et labelte3t6 7
D
ms2label+"etTe3t6@hello@78
G
Ques..13.. o )emonstrate class conce&t: to find t!e 2olume of t!e cu(e.
"oution.
ClicE the "ource" Ci,(oC a,( ju"t beloC T "u11re"" Car,i,2"
6PO,checEe(MM7 li,e Crite it#
00O"er (e5i,e( cla"" U
Public cla"" cube
D
i,t =8
i,t b8
i,t h8
00Create co,"tructor o5 a cube cla""+
1ublic cube 6 7
D
G
1ublic i,t 2et Volu'e 6 7
D
retur,6=<b<h78
G
G
Ques..15.. Use Class to in&lement t!e follo$in# for a rectan#le class6Calculate
area of t!e rectan#le.
Also: Calculate Perimeter of a rectan#le
"olution.
BeloC "u11re"" Far,i,2 U
00O"er (e5i,e( cla""
Public cla"" recta,2le
D
i,t le,2th8
i,t brea(th8
DBB ,eC i,"ta,ce o5 cla""< =G
Public recta,2le 6 7
D
le,2th4$8
brea(th4$8
G
i,t area6i,t l9i,tb7
D
le,2th4l8
brea(th4b8
retur,6le,2th<brea(th78
G
i,t 1eri'eter6i,t I9i,t b7
D
le,2th4l8
bre(th4b8
retru,6le,2thBbrea(th778
G
G
Ques..19.. Create an o(Cect rectan#le for rectan#le class..
"olution.
recta,2le rect obj4,eC recta,2le6 78
i565rb l+i"Selecte(6 77
D
re"ult4rect obj+area6l<b78
G
el"e
i565rb >+i"Selecte(677
D
re"ult4rectobj+1eri'eter6l9b78
G
te3tre"ult+"etTe3t6l,te2er+toStri,26re"ult778
Ques..1.. A ,MP+OD,, ta(le contain t!e follo$in# structure (elo$. 0rite t!e
"Q+ command to create t!e follo$in# ta(le6
6 = 7 table Create E'1lo*ee
6I( i,t 6K7 1ri'ar* Ee* 9
Na'e varchar 6&$7 ,ot ,ull9
La"tV ,a'e varchar 6=&7 ,ot ,ull9
E'ailVi( varchar 6&$7 ,ot ,ull9
Salar* i,t 6=$7 (e5ault@=$$$$@78
Ques../.. Consider t!e follo$in# ta(le named A,C?,R.
0rite t!e "Q+ command to create t!e follo$in# ta(le6if
I. )is&la' t!e names of all t!e teac!ers
Select ,a'e 5ro' teacher"8
II. )is&la' t!e names and e<&erience of allEE!e teac!ers.
Select ,a'e"9 e31erie,ce 5ro' teacher"8
III. )is&la' t!e name of all t!e teac!ers $it! e<&erience less t!an 1A.
M*S/l
Select ,a'e" 5ro' teacher" e31erie,ceN=$8
IV. )is&la' details of all t!e teac!ers $it! e<&erience #reater t!an & and
less t!an 1/8
Select 5ro' teacher" Chere e31erie,ce betCee, & a,( =>8
V. )is&la' em&lo'ee Id of all t!e teac!ers $it! #ender as FMF..
Select e'1i( 5ro' teacher" Chere 2e,(er4@'@8
VI. )is&la' all ro$s sorted in descendin# of e<&eriences.
Select < 5ro' teacher" or(er b* e31erie,ce (e"c8
VII. )is&la' details of all t!e teac!ers $it! name startin# $it! F2F..
Select < 5ro' teacher" Chere ,a'e liEe @vJ@8
VIII. Add a ne$ ro$ 413/:F2anditaF:FfF:197G
I,"ert i,to teacher" value" 6=;>9@va,(ita@9@5@
8
=&78
IH. C!an#e t!e de&artment from P!'sics to Mat!s for all t!e teac!ers of
&!'sics de&artment.
O1(ate teacher" "et (e1t4@'ath"@ Chere (e1t4@1h*"ic"@8
H. )is&la' all t!e teac!ers $it! name !a2in# 5 c!aractefB
Select<5ro' teacher" Chere ,a'e liEe P#####P8
Ques..3.. Consider t!e follo$in# ta(les stationar' and consumer...
0rite t!e "Q+ command for t!e statement 4i7 to 4iii) to #i2e t!e out&ut for "Q+
1uries 4i2 7
to 427.
4 i 7 o dis&la' t!e consumerName :Address from ta(le Consumer and
Com&an' and Price
from ta(le stationar'..
"elect C +Co,"u'erNa'e 9C+ A((re"" 9S+ Co'1a,* 9 S+
Price 5ro' "tatio,ar*9 Co,"u'er Chere S+"Vi(4 C+"Vi(8
4 ii 7 )is&la' all t!e consumer 0!o (elon#s to )el!i.
Select<5ro'9co,"u'er Chere a((re""4@ Delhi@8
4 iii 7 )is&la' t!e ConsumerName : Address from ta(le Consumer and
"tationar' Name and com&an' from ta(le stationar' $!ere &rice in (et$een >
and 19..
Select C+ Co,"l'erNa'e 9 C+ A((re"" 9 ST Statio,ar*Na'e 9 S+ Co'1a,* 9
5ro'
Stato,ar* S 9 Co,"u'er C Chere S+1rice betCee, W a,( =&
a,( S+"Vi(4C+"Vi(
4 i2 7 "elect C.ConsumerName : ". "tationar'Name : ".Price from "tationar'
" .Consumer C $!ere ".sIidJC.sIidG
Consumer Name "tationar' Name Price
Good +earner Pencil 9
0rite 0ell Gel&en 19
o&&er Pot&en 1A
0rite and dra$ Pencil ;
Moti2ation Pencil
4 2 7 "elect "."tatonar'Name : ".Price %3: C.ConsumeName from "tationar' ":
Consumer C
$!ere ".sIidJC.sJidG
"tationar' Name Consumer Name
Pencil

19 Good +earner
Gel&en 59 0rite $ell
Pot&en 3A o&&er
Pencil 1> 0rite and dra$
Pencil 19 Moti2ation
Ques...5.. 0rite t!e "Q+ Command 1 to 1> on t!e (asis of ta(le named
"U),N..
"olution.
"tudent
No
Class Name Game Grade "u&$ Grade 1
1A = "amir Cric*et - P!oto
Gra&!'
A
4i7 o dis&la' t!e names of t!e students $!o are #ettin# #rade "c" eit!er
GAM, or "UP0..
Select ,a'e 5ro' "tu(e,t Chere 2ra(e 4@C@ or 2ra(e = 4@C@8
4ii7 )is&la' t!e no. of student #ettin# #rade FAF in Cric*et.
Select cou,t 62ra(e7 5ro' "tu(e,t Chere 2ra(e @A@ a,( 2a'e4@CricEet@8
4iii7 )is&la' t!e different #ames offered in t!e sc!ool.
F
8
Select (i"ti1et 2a'e" 5ro' "tu(e,t"8
4i27 )is&la' t(K "UP0 ta*en u& (' student $!ose name start $it! FAFG
Select SOPF 5ro' "tu(e,t Chere ,a'e liEe @A@8
427 )elete t!e record of all t!e students $!ose class is =.
Delete 5ro' "tu(e,t Chere cla""4I?I8
42i7 C!an#es t!e data t'&e of t!e column 2arc!ar 45A7.
Alter table "tu(e,t 'o(i5* colu', varchar 6K$78
42ii7 )is&la' t!e structure of t!e ta(le.
De"c "tu(e,t"8
42iii7 )elete t!e ta(le.
Dro1 table "tu(e,t8
DATABASE
CONNECTIVIT
Ques.1. 0rite t!e code to add records in a ta(le in&ut t!rou#! a form.
"olution.
00Netbea," A11licatio, =# To a(( a ,eC roC 6"7 i, the co,tact Table
Private voi(
jButto, = Actio,Per5or'e(6java+aCt+eve,t+Actio,Eve,t evt7
D
00Declare variable a,( "tore value" retrieve( 5ro' the 5ro,t e,(
Stri,2 ,a'e 4 t5= +2etTe3t678
Stri,2 '(bile 4t5>+2etTe3t678
Stri,2 e'ail 4t5;+2ette3t678

tr*
00 thi" blocE i" e3ecute( i, ca"e o5 ,or'al e3ecutio,
{
Cla""+5or,a'e6@java+"/l+DriveMa,a2er@7:X#i Co,,ectio, co, 4 6Co,,ectio,7
DriveMa,a2er+2etCorFrr5io,
6@j(bc)'*"/l)00localho"t);;$%0cb"e@
8
@root@9@=YW$@78
State'e,t "t't46State'e,t7co,+createState'e,t6 78
Stri,2 /uer*4@INSEAT INTO CONTACT VALOES
6 ZP BNa'eBIH9HIMobileBIH9HIE'ailBHI78I
St't+e3ecute O1(ate6/uer*7
Catch 6E3ce1tio, e7
00Di"1la* a, error 'e""a2e i, the (ialo2 bo3 5or a, e3ce1tio,
-O1tio,Pa,e+"hoCMe""a2eDialo2 6,ull9@error i, Co,,ectivit*@78
G
00Thi" 1art o5 the co(e i" u"e( to e3it 5ro' the a11licatio,
Private voi(
jButto,>Actio,Per5or'e(6java+aCt+ eve,t+ Actio, Eve,t evt7
D
S*"te'+e3it6O78
G
Ques../. 0rite a code to Modif' t!e a(o2e a&&lication to !andle (asic data
2alidations..
"olution.
00Netbea," A11licatio, = 6Cith Data vali(atio,7
00#to a(( a ,eC roC 6"[ i, the co,tact table
Private voi(
jButto, Actio, Per5or'e(6java+aCt+ eve,t+ Actio, Eve,t evt7
{
Stri,2 ,a'e4t5=+2etTe3t6 78
Sti,2 'obiIe4t5>+2etTe3t6 78
Stri,2 e'ail4t5;+2etTe3t6 78
00 checE i5 a,* o5 the variable i" e'1t* a,( accor(i,2l* (i"1la* a, a11ro1riate error
'e""a2e+
l56,a'e+i"E'1t*677
-O1tio,Pa,e+"hoCMe""a2eDialo2 6,ullHINar5ie ,ot e,tere(@78
El"e i5 6'obile+i" E'1t*6 77
-O1tio,1a,e+"hoCMe""a2eDialo2 6,ull9@'obile ,ot e,tere(@78
El"e i56e'ail+i" E'1t*6 77
-O1tio,1a,e+"hoCMe""a2eDialo2 6,ull9@e'ail ,ot e,tere(@78
El"e
{
tr*
}
Cla""+5or,a'e6@java+"/l+DriveMa,a2er@78
Co,,ectio, co, 4 6Co,,ectio,7
DriveMa,a2er+2etCo,,ectio, 6@j(bc)'*"/l)00localh2\tT;;$%0cb"e@9@root@9@=YW$@78
State'e,t "t't46State'e,t7co,+createState'e,t6 78
Stri,2 /uer*4@INSEAT INTO co,tact VLOES
6@MBNa'eB@MBMobileB@9HIE'ailB@78@8
St't+e3ecute O1(ate6/uer*78
t5=+"etTe3t6@ @78
t5>+"etTe3t6@ @78
t5;+"etTe3t6@ @78
{
Catch6E3ecutio, e7
{
-O1tio,1a,e+"hoCMe""a2eDialo26,ull9@error i, Co,,ectivit*@78
}
Private voi(
jButto,>Acti,Per5o'e(6java+aCt+eve,t+ Actio, Eve,t evt7
D
S*"te'+e3it6O78
}
Ques..3.. 0rite a code to dis&la' records retrie2ed from a data(ase 4(ac* end7
in a form 4front end7 one (' one..
"olution.
00Netbea," A11licatio,> 6ba"ic 1art7#To "earch 5or a 'atchi,2 roC a,( (i"1la*
corre"1o,(i,2 i,5or'atio, 5ro' the table co,tact
Private voi(
# \
jButto,Actio,Per5or'e(6java9aCt+eve,t+ Actio, Eve,t evt7
{
00"earch the table to 5i,( the recor( 'atchi,2+
00the i,1ut 'obileM,o+
Stri,2 'obile4t5=+2etTe3t6 78
I56'obile+i"E'1t*6 77
00E3ecute thi" 1art i5 te3t 5iel( i" bla,E
{
t5>+"etTe3t6@ @78
t5;+"etTe3t6@ @78
-O1tio,1a,e+"hoCMe""a2eDialo2 6,ull9@E,ter the 'obile ,o+@78
G
//thi" 1art o5 the co(e i" e3ecute( i5 the 'obile ,o+ i" i,1ut i, the te3t 5iel(
el"e
D
tr*
G
Cla""+5or,a'e6Pjava+"/l+DriveMa,a2er@78
Co,,ectio, co,46Co,,ectio,7
DriveMa,a2er+2etCo,,ectio,
6@j(bc)'*"/l)00localho"t);;$%0cb"e@9@root@9@=YW$@78
State'e,t "t't46State'e,t7co,+createState'e,t6 78
Stri,2 /uer*4@"elect ,a'e9e'ail95ro' co,tact
Fhere 'obile4M @B'obiieB@ Z8I8
Ae"ultSet r" 4 "t't+e3ecQteQuer*6/uer*78
l56r"+,e3t6 77
Stri,2 ,a'e4r"+2etStri,26@,a'e@78
00Aetrieve the ,a'e
Stri,2 e'ail4r"+2etStri,26@e'ail@78
00Aetrieve the e'ail
t5>+"etTe3t6,a'e78 t5;+"etTe3t6e'ail78
G
00Thi" 1art i" e3ecute( i5 ,o 'atchi,2 recor( i" 5ou,(
el"e
-O1tio,1a,e+"hoCMe""a2eDialo2 6,ull+@Sorr*QNo Such Mobile ,o+@78 G
Catch6E3ce1tio, e7
D
-O1tio, 1a,e+"hoCMe""a2eDialo26,ul I9@error i, co,,ectivit*@78
G
G
Private voi(
jButto,>Actio,Per5or'e(6java+aCteve,t+ Actio, Eve,t evt7
{
S*"te'+e35t6O78
}
Ques..5.. 0rite a code to dis&la' t!e details stored in t!e (ac* end (ased on
t!e name in&ut (' t!e user in a form..
"olution.
Private voi(
jButto,Actio,Per5or'e(6java+aCt+eve,t+ Actio, Eve,t evt7
{
Stri,2 ,a'e4t5=+2etTe3t6 78
If (name. isEmpty())
JOptionpane.showMessageDialog (null,"Name not Entere")!
Else
{
try
{
"lass. forname("#a$a.s%l.prf$eManager")!
"onne&tion &on'("onne&tin)
Dri$eManager.get. "onne&tion
("#(&!mys%l)**lo&alhost)++,-*&(se","root","./0,")!
1tatement stmt'(1tatement)&on.&reate1tatement()!
1tring %uery'"sele&t name,email,from &onta&t"
2here mo(ile'3 "4mo(ile4"5!6!
7esult1et rs 'stmt.e8e&ute9uery(%uery)!
int :oun ',!
while(rs.ne8t( ))
**till the re&ors in the result set
{
1tring mo(ile'rs.get1tring("Mo(ile6)!
1tring email'rs.get1tring("email")!
tf;.set<e8t(mo(ile)!
tf+.set<e8t(email)!
JOptionpane.showMessageDialog(null,
"&li&= O.>.to "ontinue")!
:oun44!
**in&rement the $aria(le to ini&ate a mat&hing
**re&or has (een foun
?
if (:oun'',)
JOptionpane.showMessageDialog (null,"1orry@ No su&h name in &onta&t list")!
?
"at&h (E8&eption e)
{
JOptionpane.showMessageDialog (null,"error in "onne&ti$ity")!
?
?
?
Ari$ate $oi
#Button;C&tionAerforme(#a$a.awt.e$ent. C&tion E$ent e$t)
{
1ystem.e8it(,)!
?
Ques..5.. Write a code to display records retrieved from the Back-end in the table
component..
Solution:
Ari$ate $oi
#Button lC&tionAerforme(#a$a.awt.e$ent. C&tion E$ent e$t)
{
Default<a(leMoel moel ' (Deault<a(leMoel)
#<a(le l.getMoel
try
{
"lass.forName("3#a$a.s%l.Dri$erManager")!
"onne&tion &on ' ("onne&tion)
Dri$erManager.get"onne&tion
("#(&)mys%l)**lo&alhost)++,-*&(se" ,"root" ,"./0,")!
1tatement stmt'(1tatement)&on.&reate1tatement( )!
1tring <name!
If (r(l.is1ele&te( ))
<name'"&onta&t"!
else
<name'" Offi&ial"@
**<he %uery is e8e&ute on ifferent ta(les epening upon the
**purpose
1tring %uery '"sele&tDfrom "4<name4"!"!
7esult1et rs ' stmt.e8e&ute9uery(%uery)!
2hile(rs.ne8t( ))
{
1tring Name'rs.get1tring("Name")!
1tring Mo(ile'rs.get1tring("Mo(ile")!
1tring Email'rs.get1tring("Email")!
Moel.a7ow (new O(#e&tfl {Name,Mo(ile,Email?)!
?
?
"at&h(E8&eption e)
{
JOptionpane.showMessageDialog (null,"error in &onne&ti$ity")!
?
?
Ari$ate $oi
#Button;C&tionAerforme(#a$a.awt.e$ent.C&tion E$ent e$t)
Default<a(leMoel moel ' (Default<ta(leMoel)
#<a(le l.getMoel( )! if rows'moel.get7ow"ount( )!
if (rowsE,)
{
for (int i',!iFrows!i44)
moel.remo$e7ow (,)!
**to remo$e all rows from &urrent moel
?
?
Ari$ate $oi
#Button+C&tionAerforme(#a$a.awt.e$ent. C&tion E$ent e$t)
{
1ystem. e8it(O)!
?

HTML
PROGRAMMES
Ques..1.. Create a $e( a&&lication to #enerate t!e $e( &a#e on t!e 2irus
information...
NHTML:
NHEAD:
NTITLE: S*"te' Securit*N0NTITLE:
N0HEAD:
NQ]Be2i,,i,2 o5 Bo(* ta2## :
NBODY b2colour 4 @*elloC@ TE.T4Pblue@
LIN^4@CYAN@ ALIIN^4@BLAC^@ VLIN^4@TEAL@:
NCENTEA: VIAOS # Vital I,5or'atio, Ae"ource" O,(er Sei_e NBA:
NP:T*1e" o5 Viru"e"N0P:
NHA SI`E4K FIDTH4&$J COLOA4@AED@: NCENTEA:
NP: ALI!N4@LET@Nu:Nb: Boot Sector Viru"Nb:Nu: NBA:
The"e viru"e" i,5ect the boot recor( o5 the "*"te'+The* cha,2e the locatio, o5 the
boot recor( Chich i" re"1o,"ible 5or loa(i,2 the O1erati,2 S*"te' i, the 'e'or*+
Boot "ector viru" beco'e" active at the ti'e o5 booti,2#the 'achi,e++
E3a'1le# Di"E ^iller9 Sto,e viru" N0P:
Ques../.. Create a $e( &a#e on t!e PuLLle usin# ?M+
NHTML:
NHEAD:
NTITLE:PO``LESN0TITLE:
N0HEAD:
NBODY B!COLOA4@aE;EKA@:
NH= ALI!N4@CENTEA@:The Pu__leN0H=:
NCOMMENT:ShoCi,2 u"e o5 5or'atti,2 ele'e,t"N0COMMENT:
Ques...3.. Create a $e( &a#e (ased on FQUIM COMP,IIONF usin# list
items...
NHTML:
NHEAD: NTITLE:QOI`N0TITLE: N0HEAD:
NBODY:
NONT ACE 4 @Ti'e" NeC Ao'a,@ "i_e "@K@:
NCENTEA:QOI` ON COMPOTEASN0CENTEA:
NIM! BOADEA4@&@ SAC4@Q+OI`+j12@ AII!N4@AI!HT@:
NHA color4@BLAC^@:
NCOMMENT:Be2i,,i,2 o5 5ir"t or(ere( li"tN0COMMENT:
Xf
NOL STAAT4=:
NLI:A Catho(e Aa* Tube i" 5ou,( i, Chatb
NCOMMENT:Be2i,,i,2 o5 "eco,( or(ere( li"tN0COMMENT:
NOL STAAT4= TYPE4a:
NLI:CPO
NLI:Pri,ter
NLI:Mo,itor
NLI:AII o5 the above
N0OL:
NHA:
NLI:The out1ut /ualit* o5 a 1ri,ter i" 'ea"ure( b* NOL STAAT4= TYPE4a:
NLI:Dot 1er i,ch++
NLI:Dot 1er "/+ i,ch+
NP:A Nl:1u__leN0l: i" a 1roble' or e,i2'a that te"t" the i,2e,uit* o5 the "olver+ I, a
ba"ic 1u__le 9o,e i" i,te,(e( to 1iece to2ether object" 61u__le 1iece"7 i, a lo2ical
Ca* i, or(er to co'e u1 Cith the (e"ire( "ha1e9 1icture" or "olutio,++Let u" ,oC tr*
"olvi,2 a 1u__le++NBA:
NP:The 2ive, e/uatio, i" NO:Cro,2N0O:) NB:=&$ # => 4 >&&N0B:NBA:NBA0:
Nl:MoveN0l: o,e ,u'eral to 'aEe it correct++NBA :
NBA:
NBA:
NBA:
NBA:
NBA:
NBA:
NH> :The Solutio, + + + N0H>:
NP:Move the ,u'eral & 5ro' AHS to LHS to achieve NB:=&$#=>& 4
>&N0B30P:
NP:or 'ore 1u__le "ur5 the ,etN0 P:
N0BODY:
N0HTML:
NLI:Dot" 1ri,te( 1er u,it ti'e+
NLI:AII o5 the above+
N0OL:
NHA:
N0OL:
NH&:HOF DO YOO AATE THE QOES-^-NSN0H&:
NOL TYPE4CIACLE:
NLI:!OOD
NLI:AVEAA!E
NLI:BAD
N0ONT:
N0BODY:
N0HTML:

Вам также может понравиться