JDBC
JAVA DATABASE CONNECTIVITY
● Java Database Connectivity.
● It is a standard API for
database connection between
java programming language
and wide range of database.
● Creating SQL & MYSQL
statements.
● Executing SQL & MYSQL
queries in the database.
JDBC ARICHETECTURE.
JDBC Components
1.𝐉𝐃𝐁𝐂 𝐀𝐏𝐈
𝘐 𝘵 𝘱 𝘳 𝘰 𝘷 𝘪 𝘥 𝘦 𝘴 𝘷 𝘢 𝘳 𝘪 𝘰 𝘶 𝘴 𝘮𝘦 𝘵 𝘩 𝘰 𝘥 𝘴 𝘢 𝘯 𝘥 𝘪 𝘯 𝘵 𝘦 𝘳 𝘧 𝘢 𝘤 𝘦 𝘧 𝘰 𝘳 𝘦 𝘢 𝘴 𝘺
𝘤 𝘰 𝘮𝘮𝘶 𝘵 𝘢 𝘵 𝘪 𝘰 𝘯 𝘸𝘪 𝘵 𝘩 𝘵 𝘩 𝘦 𝘥 𝘢 𝘵 𝘢 𝘣 𝘴 𝘦 .
2.𝐉𝐃𝐁𝐂 𝐃𝐞𝐫𝐢𝐯𝐞𝐫 𝐌𝐚𝐧𝐚𝐠𝐞𝐫
It is used to manage the JDBC drivers and establish connection to the database.
3.𝐉𝐃𝐁𝐂 𝐓𝐄𝐒𝐓 𝐒𝐔𝐈𝐓
𝘐𝘵 𝘪𝘴 𝘶𝘴𝘦𝘥 𝘵𝘰 𝘵𝘦𝘴𝘵 𝘰𝘱𝘦𝘳𝘢𝘵𝘪𝘰𝘯 𝘴𝘶𝘤𝘩 𝘢𝘴 𝘪𝘯𝘴𝘦𝘳𝘵𝘪𝘰𝘯,
𝘥𝘦𝘭 𝘦𝘵 𝘪 𝘰𝘯 𝘢𝘯𝘥 𝘶𝘱𝘥𝘢𝘵 𝘪 𝘰𝘯.
4.𝐉𝐃𝐁𝐂 𝐎𝐃𝐁𝐂(𝐎𝐩𝐞𝐧 𝐃𝐚𝐭𝐚𝐛𝐚𝐬𝐞 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐯𝐢𝐭𝐲 )
List the interface and class used for JDBC API
[Link] Manager : The driver manager class manages a list of database drivers. It is
responsible for selecting an appropriate database drivers when establishing a connection to a
data base.
[Link] : It represents a session between the java application and the database.
[Link] : It is used to execute basic SQL queries (like SELECTION, INSERTION,
UPDATE )against the database.
[Link] set : It represents the result set of a query.
[Link] Exception : It is an exception that provides information about database -related errors.
[Link] : It is an alternative to Driver Manager for obtaining a database connection. It
is generally preferred for enterprise application because it allows for connection poolimg
and better resource management.
𝐉𝐃𝐁𝐂 𝐀𝐏𝐈 𝐖𝐨𝐫𝐤𝐢𝐧𝐠
1. 𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝘁𝗵𝗲 𝗱𝗲𝗿𝗶𝘃𝗲𝗿 𝗰𝗹𝗮𝘀𝘀 - 𝘞𝘦 𝘩𝘢𝘷𝘦 𝘵𝘰 𝘴𝘱𝘦𝘤𝘪𝘧𝘺 𝘢 𝘥𝘳𝘪𝘷𝘦𝘳 𝘧𝘰𝘳 𝘦𝘹𝘦𝘤𝘶𝘵𝘪𝘰𝘯.
𝘍𝘰𝘳 𝘯𝘢𝘮𝘦 ()
𝘌𝘨. 𝘊𝘭𝘢𝘴𝘴 𝘧𝘰𝘳𝘯𝘢𝘮𝘦(“𝘖𝘳𝘢𝘤𝘭𝘦 𝘫𝘥𝘣𝘤 𝘥𝘳𝘪𝘷𝘦𝘳)
2. 𝗖𝗿𝗲𝗮𝘁𝗲 𝗖𝗼𝗻𝗻𝗲𝗰𝘁𝗶𝗼𝗻 - 𝘨𝘦𝘵 𝘤𝘰𝘯𝘯𝘦𝘤𝘵𝘪𝘰𝘯()
•𝘤𝘳𝘦𝘢𝘵𝘦 𝘴𝘵𝘢𝘵𝘦𝘮𝘦𝘯𝘵()
3. 𝗘𝘅𝗲𝗰𝘂𝘁𝗶𝗻𝗴 𝗦𝗤𝗟 𝗼𝗿 𝗺𝘆𝗦𝗤𝗟 𝗾𝘂𝗲𝗿𝗶𝗲𝘀
•𝘦𝘹𝘦𝘤𝘶𝘵𝘦 𝘲𝘶𝘦𝘳𝘺()
4. 𝗖𝗹𝗼𝘀𝗲 𝗖𝗼𝗻𝗻𝗲𝗰𝘁𝗶𝗼𝗻 - 𝘛𝘦𝘳𝘮𝘪𝘯𝘢𝘵𝘪𝘰𝘯 𝘰𝘧 𝘤𝘰𝘯𝘯𝘦𝘤𝘵𝘪𝘰𝘯.
𝘌𝘨:𝘤𝘰𝘯𝘯. 𝘤𝘭𝘰𝘴𝘦()
Advantages
● Easy to use.
● Easy to connect.
Disadvantages
● Difficulty to handling large data results.
● Performance overhead.