Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

‭JDBC‬

‭What is API‬
‭API stands for Application Programming Interface.‬
‭API is a collection of different interfaces, implementation classes or‬
‭helper classes. The main objective of the creative API is exchange of‬
‭the info. between two software components.‬
‭API mainly classified into 2 types 1)Private API 2)Open API‬

‭ hat is JDBC?‬
W
‭JDBC stands for java database connectivity.‬
‭JDBC is a technology which can be used to establish the connection‬
‭between java and database software.‬
‭Incase of JDBC we have to use database API to communicate with‬
‭database software which is also known as JDBC API.‬

‭ ava app. can communicate with database app. by using‬


J
‭following component of db API‬
‭A)Driver :- is responsible to convert object oriented instructions into‬
‭simple sql‬‭format as well as sql info. will be converted into object‬
‭oriented format.‬
‭B)Connection :- It provides a network between java and database‬
‭applications.‬
‭C) Statement :- It acts as an input container. which means we can‬
‭write sql instruction by using statement object‬
‭D) ResultSet :- It acts as an output Container. which means multiple‬
‭table record will be store into resultset object‬

‭ hat is Maven?‬
W
‭Maven is a Project Management tool specifically dev. for java‬
‭application.‬
‭By using Maven we can automate the project Management process.‬
‭The Maven tool is developed by Apache Software Foundation.‬

‭Chetan Ghodekar‬
‭JDBC‬
‭ o with the help of maven developers can easily create project‬
S
‭structure.‬
‭Superior dependency management i.e. Project will automatic‬
‭updating, dependency closure.‬
‭Dependency management :- Maven encourages to use a central‬
‭repository of jars and other dependencies.‬
‭Maven is a build automation tool used primarily for Java projects.‬
‭Maven can also be used to build and manage projects written in C#,‬
‭Ruby, Scala etc.‬

‭ hat are the Steps to develop a JDBC app?‬


W
‭we have to follow 6 steps to developed jdbc app‬
‭1)Load & register the driver -> To dev. JDBC application its‬
‭mandatory load and register the driver software.‬
‭2)Establish the connection -> We can establish the connection‬
‭between java and database applications by using getConnection().‬
‭3)create a statement of platform -> After connection we have to create‬
‭a statement platform inorder to execute sql query.‬
‭We can create platform by using 3 Ways‬
‭A)Statement(Interface)‬
‭B)PreparedStatement(Interface)‬
‭C)CallableStatement(Interface)‬
‭4)Execute query -> We can execute sql query by using 3 diff. ways‬
‭1) executeUpdate() can be used for the execution the dml‬
‭set‬
‭2)executeQuery() can be used to for the execution dql‬
‭statement‬
‭3)execute() is capable to execute dml as well as dql‬
‭statement‬

‭Chetan Ghodekar‬
‭JDBC‬
‭ )process resultset -> After the execution of the query database‬
5
‭server will return a group of multiple records. Which will be present‬
‭inside the result set object.‬
‭6)close costly resources -> After JDBC transaction we have to close‬
‭all the costly resources present inside the java file.‬

‭ ow to create platform by using different types of statements‬


H
‭In JDBC we can create statement platform by using three interfaces‬
‭1)Statement(I)‬
‭2)Prepared Statement(I)‬
‭3)Callable Statement(i)‬
‭Statement(I) can be used to create a basic platform to execute sql‬
‭query.‬
‭Statement(I) is mainly used to execute different sql query.‬
‭In the case of Statement(i) sql query will be compiled and executed for‬
‭every transaction.in Statement(I) We can't use place holders.‬

‭ hat is a placeholder?‬
W
‭A SQL prepared statement in JDBC terms is a complete SQL‬
‭statement with placeholders for values. The placeholder is‬‭the‬
‭question mark and is replaced with a value at run time‬‭.‬
‭A placeholder is a character, word, or string of characters that‬
‭temporarily takes the place of the final data.‬

‭ repared Statement(I) extends the properties of statement(I).‬


P
‭We can use Prepared Statement(I) to execute the same sql query‬
‭multiple times.In case of prepared Statement(I) sql query will be‬
‭compiled once and executed multiple times.In Prepared Statement(I)‬
‭Supports Placeholders for dynamic values.‬

‭What is Callable statement‬

‭Chetan Ghodekar‬
‭JDBC‬
‭ Callable statement is a special purpose statement which can be‬
A
‭used to execute stored functions and stored procedures.‬
‭Callable statement(I) extends the properties of prepared Statement.‬
‭To create a platform by using Callable statements we need to call the‬
‭PrepareCall() method.‬

‭ hat is Stored Function‬


W
‭Stored Function can be used to develop business logic by using sql.‬
‭It acts as a container for different sql statements.‬
‭Stored functions are based on reusability components in case‬
‭Database.‬
‭To develop a Stored function We have to use special syntax and rules‬
‭of sql.‬

‭ hat is the stored procedure?‬


W
‭Stored procedure acts as a container for multiple sql queries.‬
‭We can use stored procedures to execute different sql query at same‬
‭time.‬
‭We can not develop simple business logic using procedure.‬

‭ xplain DAO/DTO design pattern‬


E
‭A) DAO/DTO design pattern is mainly used in the developed of‬
‭database application.‬
‭1) DAO class -> DAO stands for DATA ACCESS OBJECT.‬
‭DAO class is a simple java class where we can develop jdbc logic.‬
‭DAO class directly communicates with database vendors.‬

‭ )DTO class -> DTO stands for DATA TRANSFER OBJECT.‬


2
‭DTO class is also known as model class/java bean class.‬
‭The DTO class is responsible for transferring the data from one layer‬
‭to another layer.‬

‭Chetan Ghodekar‬

You might also like