While making a JDBC connection we go through the following steps : // Step 1: Register the database driver by using: // Class.forName (\" driver class for that specific database\" ); Class.forName("com.mysql.jdbc.Driver"); // Step 2: Create a database connection using: // Connection con = DriverManager.getConnection (url, username, password); Conne...

Read More

In JDBC (Java Database Connectivity) there are 3-types of statements that we can use to interact with the Database. These are as following : Statement PreparedStatement CallableStatement Statement : Statement represents the base statements interface. In terms of efficiency, it is suitable to use Statement only when we know that we will not need to ...

Read More

When we call Class.forName (driver class). Inside the driver class there will be a static initializer block that is executed when it is loaded for the first time. It calls DriverManager.registerDriver (instance of driver), thus adding the driver to a chain of JDBC drivers.

Read More

In this post we have learned about different types of statements in JDBC and why we consider prepared statement is a better option than using statements. But there are some scenarios when Statement can perform better that PreparedStatements. Consider the following example: Because Prepared Statement objects are pre-compiled, their execution can be ...

Read More

There are mainly four type of JDBC drivers available. They are: Type 1 : JDBC-ODBC Bridge Driver - A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some ODBC native code and in many cases native database client code must be loaded on each client machine that uses this type of driver. Hence, this kind of driver is ...

Read More

Type 4  (JDBC Net pure Java Driver) is the fastest JDBC driver.  Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).

Read More

Transaction: A collection of DML statements that form a logical unit of work is called a transaction. A transaction is a group of operations that have the following properties: atomic, consistent, isolated, and durable (ACID). When a connection is created using JDBC, by default it is in auto-commit mode. This means that each SQL statement is treate...

Read More

A collection of DML statements that form a logical unit of work is called a transaction. A transaction is a group of operations that have the following properties: atomic, consistent, isolated, and durable (ACID). Following are the definition of each of this property. Atomic: Either all of the operations in the transaction succeed or none of the op...

Read More

What is JDBC ? Java Database Connectivity (JDBC) is an API for Java language which defines how a client may connect to a database. Why Do We Need JDBC ? Since ODBC(https://en.wikipedia.org/wiki/Open_Database_Connectivity) uses C for connectivity where as JDBC API was created based on ODBC as its a JAVA API moreover it offers pure Java interface for...

Read More

Exceptions in JDBC: java.sql.SQLException is a core JDBC exception class that provides information about database access errors and other errors. Most of the JDBC API methods throws SQLException. Extends the java.lang.Exception class java.sql.BatchUpdateException : a BatchUpdateException which provides an update counts for all commands that were su...

Read More

SQL JDBC Exception Handling : SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do, they simply alert the user that something did not happen as planned. For example, a warning might let you know that a privilege you attempted to revoke was n...

Read More

Method forName() is a static method of java.lang.Class. This can be used to dynamically load a class at run-time. Class.forName() loads the class if its not already loaded. It also executes the static block of loaded class. Then this method returns an instance of the loaded class. So a call to Class.forName(‘MyClass’) is going to do following Load ...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself