b)2nd form of API:
JDBC API:
It was given by Sun micro System to achieve loose coupling
between Java application and Database Server.
It contains Interfaces and Helper Class in the form of jar file.
It is distributed into 2 different packages namely java.sql and javax.sql
The interfaces of JDBC API are Driver, Connection, Statement,
PreparedStatement, CallableStatement, ResultSet, MetaData, etc.
JDBC API contains only one helper class in it by name DriverManager.
JDBC DRIVER:
It is an implementation of JDBC API.
It contains implementation classes in the form of jar file.
It is always specific to the particular Database Server or Vendor.
These are provided by respective Database Server or Vendors.
Eg: Jdbc, Servlets, etc.
Note:
For us to communicate with any Database Server and perform
any data base operation, we need to have two different
components mandatorily namely JDBC API and JDBC
DRIVER.
In Java JDBC program we always write only the Consumer
or Utilization logic.
Advantages of JDBC:
We can achieve loose coupling between Java Application and
DatabaseServer.
Platform-independent.
It is the one which helps us to get connected to a particular server.
Port Number:
Oracle=1521
Different port numbers:
MYSQ=3306
MS-SQL=1433
Derby=1527
Thin-client application:
It is a light-weight software which is used to communicate with a particular Database
Server or Database Vendor.
There are 2 different categories of thin client application present namely
a) Mobile client application
b) Database client application
a) Mobile client application: Banking software, Facebook, Messenger, etc.
b) Database client application: Toad, Squirrel, SQL workbench, SQL Developer,
SQLyog, SQLultima, etc.
Host: It is a Platform on which all the Applications can be executed.
There are 2 different types of host present namely
a) Local Host b) Remote Host
a) Local Host: In this case, the applications are restricted or limited only to
thatparticular System.
Eg: Standalone application.
b) Remote Host: In case of remote host, the applications are not limited
orrestricted toany particular system.
Eg: Any Real time application.
URL (Uniform Resource Locator): It is the path using which we can access the
resources uniquely over the network.
The contents of URL are Protocol, Host +Port Number / Domain name, Resource
Name, Data (optional)
The protocol for web applications are http or https.
The protocol for JDBC is jdbc:sub-protocol .
In case of URL, data refers to Key and Value pair
which is providedby the user which is Optional.
Standard way of writing JDBC URL:
mainprotocol: subprotocol://Host+Port/dbname(optional)
For MySql Database [user name must be root password Any]
Local Host:
jdbc:mysql://localhost:3306/Studentdb?user=root&password=admin
jdbc:mysql://localhost:3306?user=root&password=admin
Remote Host:
jdbc:mysql://192.168.10.16:3306/Studentdb?user=root&password=admin
jdbc:mysql://192.168.10.16:3306?user=root&password=admi
n
For Oracle Database [user name must be Scott password must be Tiger]
Local host:
jdbc:oracle://localhost:1521/Studentdb?user=scott&password=tiger
jdbc:oracle://localhost:1521user=scott&password=tiger
Remote Host:
jdbc:oracle://192.168.10.16:1521/Studentdb?user=scott&password=tiger
jdbc:oracle://192.168.10.16:1521?user=scott&password=tiger