0% found this document useful (0 votes)
13 views35 pages

Ajp 5

Uploaded by

matetisantosh37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views35 pages

Ajp 5

Uploaded by

matetisantosh37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI

Subject:- AJP Code:- 22517


Course Code:- CO/CM/CW/IF-5I Semester:- Fifth

Prof. Vishal Chavare

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 1
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 2
E Online Exam pattern are as follows:Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AVTotal questions are: 42 Time:- 90 Minutes


CH Detail online exam pattern are as follows with chapter wise questions
AL
SH
Distribution of Marks
Unit

VI
Unit Title R U A Total
No
Level Level Level Marks
Abstract Windowing Tool
1 2 4 6 12
Kit (AWT)
2 Swing 2 2 6 10
3 Event Handling 2 2 8 12
4 Networking Basics 2 4 4 10
Interacting with
5 2 4 6 12
Database
6 Servlets 4 4 6 14
Total 14 20 36 70

• (R) Remember Level (Basic Level):-Total Question:-14 (1 mark each)


These are very simple questions and it will not take more than 15 to 20 minutes to solve.

• (U) Understand Level:- Total Question:-10 (2 marks each).


These are understand level questions, difficulty level little increases.

• (A) Apply Level:- Total Question:-18 (2 marks each).


These are apply level questions means you have to apply your knowledge to solve these
questions and again difficulty level is increases.
Msbtebook.blogspot.com Vishal Chavare
https://www.gunwantmankar.com
/ 3
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL Distribution of Marks
SH Unit
VI No
Unit Title R U A
Level Level Level Total Marks

Abstract Windowing Tool Kit


1 2 4 6 12
(AWT)

2 Swing 2 2 6 10

3 Event Handling 2 2 8 12

4 Networking Basics 2 4 4 10

5 Interacting with Database 2 4 6 12

6 Servlets 4 4 6 14

Total 14 20 36 70

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 4
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
I 5.1. Introduction to JDBC ODBC.
V
5.2. JDBC Architecture: Two tier & Three Tier Model
5.3. Types of JDBC Drivers.
5.4. Driver interfaces & Driver Manager class:
ConnectionInterface & Statement interface, Prepared
Statement interface, Resultset interface
5.5. The Essential JDBC program.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 5
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
ODBC

S H
VI • Open Data Base Connectivity
• Developed by Microsoft for the Windows platform as the way for
Windows applications to access Microsoft databases (SQL
Server, FoxPro, Access)
• Has become an industry standard
• Most data base vendors supply native, ODBC, and JDBC drivers
for their data base products .
• It was developed in C programming.
• It is low level, high performance interface that is designed
specially for relational data stores.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 6
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

JDBCAV
CH
AL• JDBC drivers implement the defined interfaces in the JDBC
S H
VI API for interacting with your database server.
• Package: java.sql
• JDBC drivers enable you to open database connections and to
interact with it by sending SQL or database commands then
receiving results with Java.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 7
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL • JDBC is a Java API that is used to connect and execute
S H
VI query for the database.
• JDBC API uses jdbc drivers to connects to the database.

8
Msbtebook.blogspot.com Vishal Chavare
https://www.gunwantmankar.com
/ 8
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
Java

S H Application

VI
JDBC
API

Data Base Drivers

Access SQL DB2 Inform MySQ Sybase


ix L
Server

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 9
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL tire architecture
• Two
S H
VI• Three tire architecture

https://www.gunwantmankar.com
Msbtebook.blogspot.com / Vishal Chavare
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
C H
L• JDBC driver implementation vary because of wide variety of
A OS, hardware, databases in which Java operates. It divides into
SH
VI 4 types:
Type 1
• JDBC-ODBC Bridge
• Type 2
• Native API, partially java
• Type 3
• JDBC Network Driver, partially
java
• Type 4
• 100% Java 1
1
https://www.gunwantmankar.com
Msbtebook.blogspot.com / Vishal Chavare 1
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH JDBC-ODBC bridge driver uses ODBC driver to connect to
• The
ALthe database.
S H • The JDBC-ODBC bridge driver converts JDBC method calls into
VI the ODBC function calls.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 12
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H • Advantages:
VI
• easy to use.
• can be easily connected to any database.
• Disadvantages:
• Performance degraded because JDBC method call
is converted into the ODBC function calls.
• The ODBC driver needs to be installed on the client
machine.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 13
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL • The Native API driver uses the client-side
S H
I libraries of the database.
V
• The driver converts JDBC method calls into
native (c/c++ API) calls of the database API.
• If we change database, we have to change native
API.
• It is not written entirely in java.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 14
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI

• Advantage:
• performance upgraded than JDBC-ODBC bridge driver.
• Disadvantage:
• The Native driver needs to be installed on the each client
machine.
• The Vendor client library needs to be installed on client
machine.
Msbtebook.blogspot.com Vishal Chavare
https://www.gunwantmankar.com
/ 15
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
H Network Protocol driver uses middleware
• CThe
AL (application server) that converts JDBC calls directly or
S H indirectly into the vendor-specific database protocol.
VI • It is fully written in java.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 16
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
A•L Advantage:
S H
I • No client side library is required because of application
V
server that can perform many tasks like auditing, load
balancing, logging etc.
• Disadvantages:
• Network support is required on client machine.
• Requires database-specific coding to be done in the middle
tier.
• Maintenance of Network Protocol driver becomes costly
because it requires database-specific coding to be done in
the middle tier.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 17
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
C H
• The thin driver converts JDBC calls directly into the vendor-
L
A specific database protocol. That is why it is known as thin
SH
VI driver.
• It is fully written in Java language.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 18
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL • Advantage:
SH
VI • Better performance than all other drivers.
• No software is required at client side or server side.
• Disadvantage:
• Drivers depends on the Database.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 19
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI • Register the driver class
• Creating connection
• Creating statement
• Executing queries
• Closing connection

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 20
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H • The forName() method of Class class is used to
VI
register the driver class.

• This method is used to dynamically load the driver


class.

• public static void forName(String className)throws


ClassNotFoundException
• Example
• Class.forName("oracle.jdbc.driver.OracleDriver");

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 21
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
A•LThe getConnection() method of DriverManager class is used to
SH
V I establish connection with the database.
• Syntax:
• 1) public static Connection getConnection(String url)th rows
SQLException
• 2) public static Connection getConnection(String url,St ring
name,String password) throws SQLException
• Example
• Connection con=DriverManager.getConnection("jdbc:o
racle:thin:@localhost:1521:xe","system","password");

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 22
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
L
•A The createStatement() method of Connection interface is used to
H
VIS create statement.
• The object of statement is responsible to execute queries with the
database.
• Syntax:
• public Statement createStatement()throws SQLExc eption
• Ex:
• Statement stmt=con.createStatement();

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 23
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
• LThe executeQuery() method of Statement interface is used to
A
H
S execute queries to the database.
I
V • This method returns the object of ResultSet that can be used to get
all the records of a table.
• Syntax:
• public ResultSet executeQuery(String sql)throws SQLEx ception
• Ex:
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 24
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL• By closing connection object statement and ResultSet will be
SH
V I closed automatically.
• The close() method of Connection interface is used to close the
connection.
• public void close()throws SQLException
• Ex:
• con.close();

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 25
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H• ResultSet interface: oracle.jdbc.driver.OracleResultSetImpl
VI
• Statement: oracle.jdbc.driver.T4CStatement
• Connection: oracle.jdbc.driver.T4CConnection
• PreparedStatement: oracle.jdbc.driver.T4CPreparedStatement

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 26
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL• It is mainly used to execute queries.
S H Few methods of Statement interface:
VI •

• public ResultSet executeQuery(String sql)


• Used to execute select query.
• public int executeUpdate(String sql)
• Used to execute create, insert, update, delete or drop etc
• public boolean execute(String sql)
• Executes the given SQL statement, which may return multiple results.
• public int [] executeBatch()
• Submits a batch of commands to the database for execution and if all
 commands execute successfully, returns an array of update counts.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 27
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H • Insert Record:
VI
• Statement st = con.createStatement();
• St.executeUpdate(“insert into dept values (‘comp’,0130,’GPAN’)”);
• Delete Record:
• Statement st = con.createStatement();
• St.executeUpdate(“delete from dept where deptno=0130”);

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 28
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H • Precompiled sql statement object.
VI • It can read runtime input parameters.
• Ex: PreparedStatement pstmt =
con.prepareStatement(“update emp set salary = ? Where id = ?”)
• CallableStatement interface used when Java interacting with database using
stored procedures.
• Ex:
• CallableStatement cstmt = null;
• String SQL = "{call getEmpName (?, ?)}";
• cstmt = conn.prepareCall (SQL);

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 29
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
L
AString
H sql = "update DEPARTMENTS set DEPARTMENT_NAME =
I S ? where DEPARTMENT_ID = ?";
V
PreparedStatement pst = con.prepareStatement(sql); pst.setString(1, "Information

Technology"); pst.setInt(2, 60);

pst.executeUpdate();

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 30
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
Interfaces Recommended Use
AL
S H Statement Use the for general-purpose access to your database.
VI
Useful when you are using static SQL statements at
runtime. The Statement interface cannot accept
parameters.

PreparedStatement Use the when you plan to use the SQL statements many
times. The PreparedStatement interface accepts input
parameters at runtime.

CallableStatement Use the when you want to access the database stored
procedures. The CallableStatement interface can also
accept runtime input parameters.

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 31
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 32
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
A•L ResultSet is table of data which represents a data from database.
SH
VI • next() method is used to move cursor to next row.
• Type of ResultSet: Bydefault TYPE_FORWARD_ONLY
• ResultSet.TYPE_FORWARD_ONLY
• ResultSet.TYPE_SCROLL_INSENSITIVE
• ResultSet.TYPE_SCROLL_SENSITIVE

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 33
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H • beforeFirst()
VI • afterLast()
• first()
• last()
• previous()
• next()
• getRow()

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 34
E Remove Watermark Wondershare

A R Msbtebook.blogspot.com
PDFelement

AV
CH
AL
S H
VI

Msbtebook.blogspot.com Vishal Chavare


https://www.gunwantmankar.com
/ 35

You might also like