Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
You can change this under Settings & Account at any time.
JDBC tutorial v1.2 (for VP STTP)
Transcript of JDBC tutorial v1.2 (for VP STTP)
First import the java.sql package which contains all the APIs required for JDBC
Load the the Driver required for making connection using JDBC
Establish a connection with the Database using the DriverManager class
A object of Statement / PreparedStatement / CallableStatement to created before execution
5.Execute the Statement
Using the Statement object execute the required SQL statement like Insert or Select query etc.
6.Get and process the ResultSet
If a select query is executed get the ResultSet object which contains the set of all records generated by the query.
7.Close the connection
Do close the connection when the objects are no longer required.
Package java.sql Class:
ResultSetMetaData Three Tier Model Two Tier Model JDBC Architecture Types of JDBC drivers Type 2 Driver (The Native-API Driver)
The JDBC type 2 driver, also known as the Native-API driver is a database driver implementation that uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API. Type 4 (The Native-Protocol Driver)
The JDBC type 4 driver, also known as the native-protocol driver is a database driver implementation that converts JDBC calls directly into the vendor-specific database protocol.The type 4 driver is written completely in Java and is hence platform independent. It is installed inside the Java Virtual Machine of the client. class Class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Class DriverManager Connection getConnection(String url)
Connection getConnection(String url, String user, String pwd)
Driver getDriver(String url)
CallableStatement prepareCall(String sql)
PreparedStatement prepareStatement(String sql)
void setAutoCommit(boolean autoCommit)
Interface Connection void close()
boolean execute(String sql)
ResultSet executeQuery(String sql)
int executeUpdate(String sql)
Interface Statement Interface PreparedStatement boolean execute()
void setT(int index, T x)
T stands for any datatype in java
Eg. Byte, String, int, double etc.
Interface ResultSet boolean absolute(int row)
XXX getXXX(int columnIndex / String colmnName )
Interface ResultSetMetaData int getColumnCount()
String getColumnName(int column)
String getColumnTypeName(int column)
String getTableName(int column)
boolean isReadOnly(int column)
boolean isWritable(int column)
Asif Rampurawala Last revised: 4th Feb, 2011 Type 3 driver (The Network-Protocol Driver)
The JDBC type 3 driver, also known as the network-protocol driver is a database driver implementation which makes use of a middle-tier between the calling program and the database. The middle-tier (application server) converts JDBC calls directly or indirectly into the vendor-specific database protocol. These drivers use a networking protocol and middleware to communicate with a server. The server then translates the protocol to DBMS function calls specific to DBMS.
Type 1 Driver (The JDBC-ODBC bridge)
The JDBC type 1 driver, also known as the JDBC-ODBC bridge is a database driver implementation that employs the ODBC driver to connect to the database. The driver converts JDBC method calls into ODBC function calls. Asst. Professor,
Vidyalankar School of Information Technology