SlideShare uma empresa Scribd logo
Java Database Connectivity 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Review 
 A session is a long-term connection that utilizes the session layer of a network 
layer protocol. 
 A session exists for each connection between a user and an instance of a running 
application. 
 Session acts as a link between the server and the client events. The session helps 
the Web server to distinguish between different users. 
 JSP uses the sessions to store unique data of a particular client connected to a 
Web application. The different methods of session object include: 
 getAttribute() 
 getAttributeNames() 
 getCreationTime() 
 getId() 
 getLastAccessedTime() 
 getMaxInactiveInterval() 
 removeAttribute() 
 setAttribute() 
 setMaxInactiveInterval() 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Review – Contd… 
 Session tracking maintains the session information and keeps track of the multiple 
requests made by the client. 
 The session tracking feature in the servlets or JSP container maintains the state of a 
Web browser. 
 Cookies are text files that are stored on the user computer, and contain the session 
Id of the user sent by the Web server. 
 The cookie is sent back to the Web server with every subsequent request made by 
the user in the same session. 
 The information in the cookies helps the Web server to identify the user, as the 
value of each cookie is unique. 
 The session ID keeps track of requests made within the same session. 
 The session ID is encoded in the URLs that are created by the JSP pages. 
 URL Rewriting works with Web browsers that do not support cookies, or the 
cookies that are disabled on a Web browser. 
 The hidden field is used to store information about a session. In addition, the 
hidden form field helps to carry the information from one HTML page to another. 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Objectives 
 Explain Java database connectivity 
 Describe various JDBC drivers 
 Explain use of JDBC in JSP 
 Describe different database operations 
 Explain use of JDBC connectivity through 
JavaBeans 
 Describe database connection pooling 
process 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Java Database Connectivity 
 Provides a programming interface that is used to request a 
connection between the application and database 
 JDBC API executes SQL statements and sends the results 
through a single API 
 JDBC API executes simple SQL queries in the Java code to 
retrieve data from database 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Java Database Connectivity 
 Five steps 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Loading the Driver 
 The driver is a Java class that translates Java 
statements to SQL statements 
 The Class.forName() method is used to load 
the driver 
 A driver class needs to be loaded to load the 
driver 
 Syntax 
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Connecting to Database 
 The java.sql package provides classes and interfaces that are used to 
interact with the database 
 The classes send the SQL queries to the database and process the 
queries 
 Syntax 
Connection con= DriverManager.getConnection(jdbc:odbc:Datasource, 
“userid”, “pwd” ) 
 The JDBC classes for creating a connection are: 
 Java.sql.Driver 
 Java.sql.DriverManager 
 Java.sql.Connection 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Create Statement 
 Sends queries and command to the database 
 Created from the Connection object 
 Syntax 
Statement stat = con.createStatement() 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Execute Query 
 Used to send SQL queries to the database 
 Returns an object of type ResultSet 
 ResultSet() object provides methods that are used to 
access data from data source 
 Syntax 
String query = “Select * from table_name”; 
ResultSet resultset = stat.executeQuery(query); 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Processing Results 
 next() method of the ResultSet object is used 
to process the results from the database 
while(rs.next()) 
{ 
rs.getRow(); 
result += "<tr>"; 
for ( int i = 1; i <= columns; i++) 
{ 
result += "<td>" + 
rs.getObject(i).toString() + "</td>"; 
} 
result += "</tr>"; 
} 
Points the cursor to next 
row 
Traversing through 
records using for loop 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
ResultSet Object Methods 
Methods Description 
getString() Takes column number as an argument and returns value 
from the specified column number as a string to the 
ResultSet object 
getInt() Takes column number as an argument and returns the 
value from the specified column number as an integer to 
the ResultSet object 
getFloat() Takes column number as an argument and returns the 
value from the specified column number as float type to 
the ResultSet object 
getDate() Takes column number as an argument and returns the 
value from the specified column number as java.sql.Date 
to the ResultSet object 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
ResultSet Object Methods- 
Cont… 
Methods Description 
findColumn() Takes a column name as a string parameter and 
returns the column index of the specified column 
name 
wasNull() Returns true if the last column value read was 
SQL NULL 
getMetaData() Returns the information about the columns of 
ResultSet object in a ResultSetMetaData 
class 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
getMetaData() methods 
Methods Syntax Description 
getColumnCou 
nt() 
int 
getColumnCount 
() 
Returns the number of columns in the 
ResultSet object 
getColumnNa 
me() 
String 
getColumnName( 
int column) 
Takes column number as a parameter 
and returns the designated column name 
getColumnTy 
pe() 
int 
getColumnType( 
int column) 
Takes column number as a parameter 
and returns the designated column’s 
SQL type from java.sql.Types. 
The types include Array, char, 
Integer, Date, and Float 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
getMetaData() Methods-Cont… 
Methods Syntax Description 
isReadOnly() boolean 
isReadOnly(int 
column) 
Takes the column number as a 
parameter and returns true if the 
designated column is not 
writable 
isSearchable() Boolean 
isSearchable(int 
column) 
Takes column number as a 
parameter and returns true if 
the specified column can be 
used in where clause. 
isNullable() int 
isNullable(int 
column) 
Returns the nullability status of 
the specified column. The 
nullability status includes, 
columnNullable, 
columnNoNulls, and 
columnNullableUnknown 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC Connectivity - Code Snippet 
<html> 
<head> 
<title>DB Test</title> 
</head> 
<body> 
<%@ page language="java" import="java.sql.* " %> 
<% 
try 
{ 
out.println("loading driver...<br>"); 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver "); 
out.println("connecting...<br>"); 
Connection con= 
DriverManager.getConnection(jdbc:odbc:Datasource, "userid ", 
"pwd ") 
out.println("querying database...<br>"); 
Statement stat = con.createStatement(); 
String query = "Select * from table_name "; 
ResultSet rs = statement.executeQuery(query); 
Importing Java.sql.* 
package 
Loading the driver 
Creating Connection 
object 
Creating Statement 
Executing the query 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC Connectivity - Code Snippet 
Cont… 
while (rs.next()) 
{ 
out.println(rs.getString(1)+ "<br>"); 
} 
rs.close(); 
Stat.close(); 
c.close(); 
} 
catch(Exception e) 
{ 
out.println("ERROR! "+e.getMessage()); 
} 
%> 
</body> 
</html> 
Processing 
results 
Closing 
connections 
Catch exception and 
display error message 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC Drivers 
 Translates Java statements to SQL statements 
 Helps applications to interact with the database, using Java’s 
built-in Driver Manager 
 JDBC driver manager maintains a list of drivers created for 
different databases 
 JDBC drivers connect the Java application to the driver specified 
in the Java program 
 Provides Java applications that are DBMS independent 
 The four types of JDBC drivers are: 
 JDBC ODBC Bridge driver 
 Native API driver 
 Network-protocol Driver 
 Native protocol driver 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC ODBC Bridge Driver 
 Type 1 driver 
 Translates JDBC API to ODBC API 
 Enables the Java applications to interact 
with any database 
 Provides platform dependence, as JDBC 
ODBC bridge driver uses ODBC 
 JDBC-ODBC bridge is useful when Java 
driver is not available for a database 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Native API Driver 
 Type 2 driver 
 Provides access to the database through C/C++ 
 Developed using native code libraries 
 Native code libraries provide access to the 
database, and improve the performance 
 Java application sends a request for database 
connectivity as a normal JDBC call to the Native 
API driver 
 Establishes the call, and translates the call to the 
particular database protocol that is forwarded to 
the database 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Network Protocol Driver 
 Type 3 driver 
 Communicates with the middle 
layer component that provides 
data connectivity 
 Manages multiple Java 
applications connecting to 
different databases 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Native Protocol Driver 
 Type 4 driver 
 Communicates directly with the 
database using Java sockets 
 Improves the performance as 
translation is not required 
 Converts JDBC queries into 
native calls used by the 
particular RDBMS 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Using JDBC in JSP 
 The java.sql.* package provides database 
access in Java 
 JDBC can be used in JSP by inserting JDBC 
query in the scriplet code 
 After compilation, the scriplet code that contains 
the query is placed in the jspService() 
method 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Database Operations 
 Accessing database requires JDBC code to perform database 
operations 
 The JDBC code includes queries for selecting, updating, inserting, or 
deleting data from the database 
 A connection object needs to be created for database access 
 The Connection object is used to generate SQL statements, which 
perform database operations 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Basic Database Operations 
Database Operations Description 
Insert Adds the specified data in the 
database on execution of the SQL 
query 
Update Edits the specified data in the 
database on execution of query 
Delete Removes the specified data from 
the database on execution of the 
query 
Select Retrieves the specified data from 
database on execution of query 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC Connectivity through 
JavaBeans 
 JavaBeans components are reusable Java classes, and can be 
put together into applications 
 JDBC connectivity through JavaBeans is an efficient way for 
interacting with database 
 The JDBC components facilitates interaction of Java Swing 
components with a database 
 JDBC connectivity through JavaBeans provides database 
access by inserting the JDBC code in scriplets 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
JDBC Connectivity through 
JavaBeans 
<%@ page import="java.sql.* " %> 
<jsp:useBean id="Account" class="AccountBean"> 
<% 
Connection connection = null; 
Statement statement = null; 
ResultSet results = null; 
AccountBean Account = new AccountBean(); 
//code for JDBC 
%> 
</jsp:useBean> 
//html code to display the results 
Import Java 
class 
Initializing 
variables 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Database Connection Pooling 
 Connection pooling is a process that manages multiple 
database connection requests 
 Connection pooling process increases the speed of data 
access, and reduces the number of database connections for 
an application 
 Connection pooling process helps in improving the 
performance of application 
 Connection pooling tasks include: 
 Pre-allocate connections 
 Manage available connections 
 Allocate new connections 
 Close connections 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Summary 
 The JDBC programming interface is used to request a connection with database to retrieve 
data 
 The JDBC API contains some classes and interfaces that connect an application to a database 
using DBMS/RDBMS, and execute the SQL queries 
 The Class.forName() method takes string as a parameter which is used to load the driver 
 java.sql.DriverManager maintains a list of drivers created for databases and connects the 
java application to the required driver 
 java.sql.Connection sends a series of SQL statements to the database and processes the SQL 
queries 
 The Statement object is created from the Connection object. The Statement object sends 
queries and commands to the database. 
 The executeQuery() method is used to send the SQL queries to the database. 
 The next() method of the ResultSet object is used to process the results from the 
database. The methods in ResultSet class include: 
 getString() 
 getInt() 
 getFloat() 
 getDate() 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Summary-Cont… 
 findColumn() 
 wasNull() 
 getMetaData() 
 The getMetaData()returns the information regarding the columns of ResultSet object in 
a ResultSetMetaData class. The getMetaData() methods include: 
 getColumnCount() 
 getColumnName() 
 getColumnType() 
 isReadOnly() 
 isSearchable() 
 isNullable() 
 JDBC drivers translate Java statements to SQL statements. 
 The JDBC driver manager connect the Java application to the driver specified in the Java 
program 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Summary-Cont… 
 JDBC drivers make Java applications DBMS independent. The four types of drivers are: 
 JDBC-ODBC bridge driver 
 Native API driver 
 Network protocol driver 
 Native protocol driver 
 The JDBC code includes queries for selecting, updating, inserting, or deleting the required 
data from the database. The basic database operations are: 
 Insert data 
 Update data 
 Delete data 
 Select data 
 Connection pooling is a process that handles multiple database connection requests 
 The tasks of Connection pooling class include: 
 Pre-allocate connections 
 Manage available connections 
 Allocate new connections 
 Close connections 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
Q & A 
©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3

Mais conteúdo relacionado

Mais procurados

Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
Arati Gadgil
 
Jdbc sasidhar
Jdbc  sasidharJdbc  sasidhar
Jdbc sasidhar
Sasidhar Kothuru
 
Hibernate
HibernateHibernate
Hibernate
Ajay K
 
Advance Java Programming (CM5I)5.Interacting with-database
Advance Java Programming (CM5I)5.Interacting with-databaseAdvance Java Programming (CM5I)5.Interacting with-database
Advance Java Programming (CM5I)5.Interacting with-database
Payal Dungarwal
 
Core java(2)
Core java(2)Core java(2)
Core java(2)
kasun dananjaya
 
Servlet basics
Servlet basicsServlet basics
Servlet basics
Santosh Dhoundiyal
 
Jdbc
JdbcJdbc
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
John Slick
 
Prg421
Prg421Prg421
Prg421
john roy
 
Java RMI
Java RMIJava RMI
Java RMI
Ankit Desai
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
jaxLondonConference
 
Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02
Hardeep Kaur
 
Bt0074 oop with java
Bt0074   oop with javaBt0074   oop with java
Bt0074 oop with java
smumbahelp
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
Kuntal Bhowmick
 
Advance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.ServletAdvance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.Servlet
Payal Dungarwal
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
suthi
 

Mais procurados (18)

Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Jdbc sasidhar
Jdbc  sasidharJdbc  sasidhar
Jdbc sasidhar
 
Hibernate
HibernateHibernate
Hibernate
 
Advance Java Programming (CM5I)5.Interacting with-database
Advance Java Programming (CM5I)5.Interacting with-databaseAdvance Java Programming (CM5I)5.Interacting with-database
Advance Java Programming (CM5I)5.Interacting with-database
 
Core java(2)
Core java(2)Core java(2)
Core java(2)
 
Servlet basics
Servlet basicsServlet basics
Servlet basics
 
Jdbc
JdbcJdbc
Jdbc
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
 
Prg421
Prg421Prg421
Prg421
 
Java RMI
Java RMIJava RMI
Java RMI
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
 
Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02Learnadvancedjavaprogramming 131217055604-phpapp02
Learnadvancedjavaprogramming 131217055604-phpapp02
 
Bt0074 oop with java
Bt0074   oop with javaBt0074   oop with java
Bt0074 oop with java
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
Advance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.ServletAdvance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.Servlet
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
 

Semelhante a 3.java database connectivity

JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
ChagantiSahith
 
Data access
Data accessData access
Data access
Joshua Yoon
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
backdoor
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
Fulvio Corno
 
Jdbc
JdbcJdbc
1.jsp application models
1.jsp application models1.jsp application models
1.jsp application models
web360
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
varun arora
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
Fulvio Corno
 
JDBC programming
JDBC programmingJDBC programming
JDBC programming
Fulvio Corno
 
Java Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptxJava Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptx
mukeshprasanth909
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
suraj pandey
 
Prashanthi
PrashanthiPrashanthi
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Sourabrata Mukherjee
 
Jdbc new
Jdbc newJdbc new
Jdbc new
sumit kushwah
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Jdbc
JdbcJdbc
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
Dharani Kumar Madduri
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.pptFinal Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 

Semelhante a 3.java database connectivity (20)

JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
Data access
Data accessData access
Data access
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
 
Jdbc
JdbcJdbc
Jdbc
 
1.jsp application models
1.jsp application models1.jsp application models
1.jsp application models
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
 
JDBC programming
JDBC programmingJDBC programming
JDBC programming
 
Java Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptxJava Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptx
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Prashanthi
PrashanthiPrashanthi
Prashanthi
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
Jdbc new
Jdbc newJdbc new
Jdbc new
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
 
Jdbc
JdbcJdbc
Jdbc
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.pptFinal Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
 

Último

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 

Último (20)

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 

3.java database connectivity

  • 1. Java Database Connectivity ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 2. Review  A session is a long-term connection that utilizes the session layer of a network layer protocol.  A session exists for each connection between a user and an instance of a running application.  Session acts as a link between the server and the client events. The session helps the Web server to distinguish between different users.  JSP uses the sessions to store unique data of a particular client connected to a Web application. The different methods of session object include:  getAttribute()  getAttributeNames()  getCreationTime()  getId()  getLastAccessedTime()  getMaxInactiveInterval()  removeAttribute()  setAttribute()  setMaxInactiveInterval() ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 3. Review – Contd…  Session tracking maintains the session information and keeps track of the multiple requests made by the client.  The session tracking feature in the servlets or JSP container maintains the state of a Web browser.  Cookies are text files that are stored on the user computer, and contain the session Id of the user sent by the Web server.  The cookie is sent back to the Web server with every subsequent request made by the user in the same session.  The information in the cookies helps the Web server to identify the user, as the value of each cookie is unique.  The session ID keeps track of requests made within the same session.  The session ID is encoded in the URLs that are created by the JSP pages.  URL Rewriting works with Web browsers that do not support cookies, or the cookies that are disabled on a Web browser.  The hidden field is used to store information about a session. In addition, the hidden form field helps to carry the information from one HTML page to another. ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 4. Objectives  Explain Java database connectivity  Describe various JDBC drivers  Explain use of JDBC in JSP  Describe different database operations  Explain use of JDBC connectivity through JavaBeans  Describe database connection pooling process ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 5. Java Database Connectivity  Provides a programming interface that is used to request a connection between the application and database  JDBC API executes SQL statements and sends the results through a single API  JDBC API executes simple SQL queries in the Java code to retrieve data from database ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 6. Java Database Connectivity  Five steps ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 7. Loading the Driver  The driver is a Java class that translates Java statements to SQL statements  The Class.forName() method is used to load the driver  A driver class needs to be loaded to load the driver  Syntax Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 8. Connecting to Database  The java.sql package provides classes and interfaces that are used to interact with the database  The classes send the SQL queries to the database and process the queries  Syntax Connection con= DriverManager.getConnection(jdbc:odbc:Datasource, “userid”, “pwd” )  The JDBC classes for creating a connection are:  Java.sql.Driver  Java.sql.DriverManager  Java.sql.Connection ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 9. Create Statement  Sends queries and command to the database  Created from the Connection object  Syntax Statement stat = con.createStatement() ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 10. Execute Query  Used to send SQL queries to the database  Returns an object of type ResultSet  ResultSet() object provides methods that are used to access data from data source  Syntax String query = “Select * from table_name”; ResultSet resultset = stat.executeQuery(query); ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 11. Processing Results  next() method of the ResultSet object is used to process the results from the database while(rs.next()) { rs.getRow(); result += "<tr>"; for ( int i = 1; i <= columns; i++) { result += "<td>" + rs.getObject(i).toString() + "</td>"; } result += "</tr>"; } Points the cursor to next row Traversing through records using for loop ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 12. ResultSet Object Methods Methods Description getString() Takes column number as an argument and returns value from the specified column number as a string to the ResultSet object getInt() Takes column number as an argument and returns the value from the specified column number as an integer to the ResultSet object getFloat() Takes column number as an argument and returns the value from the specified column number as float type to the ResultSet object getDate() Takes column number as an argument and returns the value from the specified column number as java.sql.Date to the ResultSet object ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 13. ResultSet Object Methods- Cont… Methods Description findColumn() Takes a column name as a string parameter and returns the column index of the specified column name wasNull() Returns true if the last column value read was SQL NULL getMetaData() Returns the information about the columns of ResultSet object in a ResultSetMetaData class ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 14. getMetaData() methods Methods Syntax Description getColumnCou nt() int getColumnCount () Returns the number of columns in the ResultSet object getColumnNa me() String getColumnName( int column) Takes column number as a parameter and returns the designated column name getColumnTy pe() int getColumnType( int column) Takes column number as a parameter and returns the designated column’s SQL type from java.sql.Types. The types include Array, char, Integer, Date, and Float ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 15. getMetaData() Methods-Cont… Methods Syntax Description isReadOnly() boolean isReadOnly(int column) Takes the column number as a parameter and returns true if the designated column is not writable isSearchable() Boolean isSearchable(int column) Takes column number as a parameter and returns true if the specified column can be used in where clause. isNullable() int isNullable(int column) Returns the nullability status of the specified column. The nullability status includes, columnNullable, columnNoNulls, and columnNullableUnknown ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 16. JDBC Connectivity - Code Snippet <html> <head> <title>DB Test</title> </head> <body> <%@ page language="java" import="java.sql.* " %> <% try { out.println("loading driver...<br>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver "); out.println("connecting...<br>"); Connection con= DriverManager.getConnection(jdbc:odbc:Datasource, "userid ", "pwd ") out.println("querying database...<br>"); Statement stat = con.createStatement(); String query = "Select * from table_name "; ResultSet rs = statement.executeQuery(query); Importing Java.sql.* package Loading the driver Creating Connection object Creating Statement Executing the query ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 17. JDBC Connectivity - Code Snippet Cont… while (rs.next()) { out.println(rs.getString(1)+ "<br>"); } rs.close(); Stat.close(); c.close(); } catch(Exception e) { out.println("ERROR! "+e.getMessage()); } %> </body> </html> Processing results Closing connections Catch exception and display error message ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 18. JDBC Drivers  Translates Java statements to SQL statements  Helps applications to interact with the database, using Java’s built-in Driver Manager  JDBC driver manager maintains a list of drivers created for different databases  JDBC drivers connect the Java application to the driver specified in the Java program  Provides Java applications that are DBMS independent  The four types of JDBC drivers are:  JDBC ODBC Bridge driver  Native API driver  Network-protocol Driver  Native protocol driver ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 19. JDBC ODBC Bridge Driver  Type 1 driver  Translates JDBC API to ODBC API  Enables the Java applications to interact with any database  Provides platform dependence, as JDBC ODBC bridge driver uses ODBC  JDBC-ODBC bridge is useful when Java driver is not available for a database ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 20. Native API Driver  Type 2 driver  Provides access to the database through C/C++  Developed using native code libraries  Native code libraries provide access to the database, and improve the performance  Java application sends a request for database connectivity as a normal JDBC call to the Native API driver  Establishes the call, and translates the call to the particular database protocol that is forwarded to the database ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 21. Network Protocol Driver  Type 3 driver  Communicates with the middle layer component that provides data connectivity  Manages multiple Java applications connecting to different databases ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 22. Native Protocol Driver  Type 4 driver  Communicates directly with the database using Java sockets  Improves the performance as translation is not required  Converts JDBC queries into native calls used by the particular RDBMS ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 23. Using JDBC in JSP  The java.sql.* package provides database access in Java  JDBC can be used in JSP by inserting JDBC query in the scriplet code  After compilation, the scriplet code that contains the query is placed in the jspService() method ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 24. Database Operations  Accessing database requires JDBC code to perform database operations  The JDBC code includes queries for selecting, updating, inserting, or deleting data from the database  A connection object needs to be created for database access  The Connection object is used to generate SQL statements, which perform database operations ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 25. Basic Database Operations Database Operations Description Insert Adds the specified data in the database on execution of the SQL query Update Edits the specified data in the database on execution of query Delete Removes the specified data from the database on execution of the query Select Retrieves the specified data from database on execution of query ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 26. JDBC Connectivity through JavaBeans  JavaBeans components are reusable Java classes, and can be put together into applications  JDBC connectivity through JavaBeans is an efficient way for interacting with database  The JDBC components facilitates interaction of Java Swing components with a database  JDBC connectivity through JavaBeans provides database access by inserting the JDBC code in scriplets ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 27. JDBC Connectivity through JavaBeans <%@ page import="java.sql.* " %> <jsp:useBean id="Account" class="AccountBean"> <% Connection connection = null; Statement statement = null; ResultSet results = null; AccountBean Account = new AccountBean(); //code for JDBC %> </jsp:useBean> //html code to display the results Import Java class Initializing variables ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 28. Database Connection Pooling  Connection pooling is a process that manages multiple database connection requests  Connection pooling process increases the speed of data access, and reduces the number of database connections for an application  Connection pooling process helps in improving the performance of application  Connection pooling tasks include:  Pre-allocate connections  Manage available connections  Allocate new connections  Close connections ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 29. Summary  The JDBC programming interface is used to request a connection with database to retrieve data  The JDBC API contains some classes and interfaces that connect an application to a database using DBMS/RDBMS, and execute the SQL queries  The Class.forName() method takes string as a parameter which is used to load the driver  java.sql.DriverManager maintains a list of drivers created for databases and connects the java application to the required driver  java.sql.Connection sends a series of SQL statements to the database and processes the SQL queries  The Statement object is created from the Connection object. The Statement object sends queries and commands to the database.  The executeQuery() method is used to send the SQL queries to the database.  The next() method of the ResultSet object is used to process the results from the database. The methods in ResultSet class include:  getString()  getInt()  getFloat()  getDate() ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 30. Summary-Cont…  findColumn()  wasNull()  getMetaData()  The getMetaData()returns the information regarding the columns of ResultSet object in a ResultSetMetaData class. The getMetaData() methods include:  getColumnCount()  getColumnName()  getColumnType()  isReadOnly()  isSearchable()  isNullable()  JDBC drivers translate Java statements to SQL statements.  The JDBC driver manager connect the Java application to the driver specified in the Java program ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 31. Summary-Cont…  JDBC drivers make Java applications DBMS independent. The four types of drivers are:  JDBC-ODBC bridge driver  Native API driver  Network protocol driver  Native protocol driver  The JDBC code includes queries for selecting, updating, inserting, or deleting the required data from the database. The basic database operations are:  Insert data  Update data  Delete data  Select data  Connection pooling is a process that handles multiple database connection requests  The tasks of Connection pooling class include:  Pre-allocate connections  Manage available connections  Allocate new connections  Close connections ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3
  • 32. Q & A ©FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3