Upload
snehil
View
213
Download
0
Embed Size (px)
Citation preview
7/25/2019 JDBC.pptx
1/26
JDBC Objects
Chapter 6J2EE Complete Reference
Jim Keogh
7/25/2019 JDBC.pptx
2/26
Agenda
JDBC Concept
JDBC Driver !pes
JDBC "ac#ages Brief Overvie$ of JDBC process
Database Connection
Connection "ool
7/25/2019 JDBC.pptx
3/26
7/25/2019 JDBC.pptx
4/26
Connect to Database
Loading the JDBCDriver
Connecting to the Database
7/25/2019 JDBC.pptx
5/26
Accessing the database
Create and execute a SQL Statement
7/25/2019 JDBC.pptx
6/26
"rocess Data
"rocess Data ret%rned b! DB&'
7/25/2019 JDBC.pptx
7/26
erminate the connection
he easieststatement (
7/25/2019 JDBC.pptx
8/26
Database Connection
)more than one $a!*
+sing +R,(
7/25/2019 JDBC.pptx
9/26
Database Connection
)more than one $a!*
+sing %ser -D and pass$ord
7/25/2019 JDBC.pptx
10/26
Connection "ool
Connecting to database %singConnection "ool
7/25/2019 JDBC.pptx
11/26
'tatement Objects
Contains methods(
./ e0ec%te1%er!)*
Ret%rns Res%lt'et objects that contains
ro$s3 col%mns3 metadata/2/ e0ec%te)*
+sed $hen there ma! be m%ltiple res%ltsret%rned
4/ e0ec%te+pdate)*
+sed to e0ec%te DE,EE and +"DAE 5%eries
Ret%rns the n%mber of ro$s aected/
7/25/2019 JDBC.pptx
12/26
7/25/2019 JDBC.pptx
13/26
"repared'tatement
'1, 1%er! m%st be compiled before DB&'processes the 5%er!/
Compiling occ%rs after one of the 'tatement classe0ec%tion method is called/
Compiling a 5%er! is an overhead/
Acceptable if 5%er! is called once/
E0pensive if the 5%er! is called several times/
A '1, 1%er! is precompiled %sing"repared'tatement/
7/25/2019 JDBC.pptx
14/26
7/25/2019 JDBC.pptx
15/26
Callable'tatement
+ses 4 t!pes of parameters $hencalling a stored proced%re(
IN :Contains data that needs to bepassed to the stored proced%re
OUT:Contains val%e that is ret%rned b!stored proced%re/
INOUT:'ingle parameter that is %sed topass and store parameter to and fromstored proced%re/
7/25/2019 JDBC.pptx
16/26
7/25/2019 JDBC.pptx
17/26
Res%lt'et
7/25/2019 JDBC.pptx
18/26
7/25/2019 JDBC.pptx
19/26
'rollableRes%lt'et
7rst)* 8irt%al c%rsor moved to 7rst ro$
last)*8irt%al c%rsor moved to last ro$
previo%s)*8irt%al c%rsor moved to previo%s ro$
absol%te)*"ositions the c%rsor at the ro$ n%mberspeci7ed as a parameter to the method
relative)* moves the c%rsor to speci7ed n%mber ofro$s/ he parameter can be positive or negative/
getRo$)* gets the integer that represents then%mber of the c%rrent ro$
7/25/2019 JDBC.pptx
20/26
+sage
7/25/2019 JDBC.pptx
21/26
-mplementation
7/25/2019 JDBC.pptx
22/26
+pdatable Res%lt'et
7/25/2019 JDBC.pptx
23/26
Delete Ro$ in Res%lt'et
7/25/2019 JDBC.pptx
24/26
-nsert Ro$
7/25/2019 JDBC.pptx
25/26
&etadata
&etadata is data abo%t data
J2EE component retrieves metadataabo%t the database b! callingget&etaData)* of Connection object/
his method ret%rnsDatabase&etaData object containing
information abo%t database and itscomponents/
7/25/2019 JDBC.pptx
26/26
Retrieving information
Database&etaData object has the follo$ing f%nctionsto retrieve the information contained in the object/