JDBC 1
JDBC 1
===========================================
SQL
JDBC
Servlets
JSP
HTML
CSS
JavaScript
JDBC Drivers
============
Database is stored in its own format. No computer program can directly access them.
Javasoft developed a set of API to interact with ODBC drivers. They are called JDBC
drivers
JDBC-ODBC Bridge
JDBC Drivers
==============
JDBC-ODBC Bridge Driver (Type-I)
Native API Driver (Type-II)
Network Protocol Driver (Type-III)
Native Protocol Driver (Type-IV)
Thin Driver
oracle->main package
jdbc->sub package
driver->sub sub package
OracleDriver->class name
Registering to mysql
Class.forName("com.mysql.jdbc.Driver");
com.mysql.cj.jdbc.Driver
3) Opening of Connection
=====================
To open connection, the connection object is linked with DriverManager class.
Connection con=DriverManager.getConnection("jdbc_url","user_name","password");
To Connect to Oracle
=====================
In oracle instead of database, users are created.
Create user user_name identified by password;
grant all privileges to user_name;
connect user_name/password;
Create table.....
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521","user","pwd");
MySQL
======
Create database data_base;
use database;
Create table.....
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/database","user","pwd"
);
Statment stmt=con.createStatement();