Environment Setup

For developing along with a JDBC, we must setup a environment of JDBC for example we are operating on windows platform.

Install Java

Install J2SE 5.0 (JDK 5.0) from official website of java

We should the following environment variables to set as below

e.g. C:\Program Files\Java\jdk1.5.0_20\jre\lib.

  • PATH:Environment variable should have proper JRE bin,

e.g. C:\Program Files\Java\jre1.5.0_20\bin.

  • Double click on control panel in that settings select the advanced tab and click on Environment
  • Then check the variables to set properly are not.

Install Database

For a course running a database with a table is a query and solve.

Install a database which is better for you

  • MySQL DB:It is an open source database we can download it from MySQL Official website .And download,install administrationof MYSQL   have installed the driver at C:\Program Files\MySQL\mysql-connector-java-5.1.8.

CLASSPATH: variable to C:\Program Files\MySQL\mysql-connector-java-             5.1.8\mysql-connector-java-5.1.8-bin.jar.

  • Oracle establishment is managerial apparatus called Enterprise Manager. JDBC drivers are as a piece of the establishment. Install Database Drivers

The JDK involves a JDBC-ODBC Bridge driver which makes a Open Database Connectivity (ODBC) drivers accessible to programmers using a JDBC API.

Connection with Data Base:

There are 5 steps involved to connect java application with data base using a JDBC

  • Driver class should be registered
  • Creating a connection
  • Creating a statement
  • Executing a queries
  • Closing a connection
  1. Register a driver class

    The forName( ) method is used to register a driver class this technique is utilized to powerfully stack the driver class.

           Syntax of forNAME( ) Method :

          Public void static forName(String className)throws ClassNotFoundException

  1. Create a Connection object( ):

    The getConnection( )strategy for Driver Manager class is utilized to build up association with the database.

        Syntax of getConnection() method:

public static Connection getConnection(String url)throws SQLException

public static Connection getConnection(String url,String name,String password)

             throws SQLException

3.      Create the Statement object:

The createStatement() technique for Connection interface is utilized to make explanation,                                                           the question of proclamation is mindful to execute inquiries with the database.

         Syntax of createStatement() method:

          public Statement createStatement()throws SQLException

4.      Execute the query:

The executeQuery() technique for Statement interface is utilized to execute questions to            the database. This strategy restores the protest of ResultSet that can be utilized to get every one of the records of a table .

            Syntax of executeQuery() method:

            public ResultSet executeQuery(String sql)throws SQLException

5.      Close the connection object

The executeQuery() technique for Statement interface is utilized to execute questions to  the database. This technique restores the protest of ResultSet that can be utilized to get every one of the records of a table.

            Syntax of close() method:

            public void close()throws SQLException

 

 Types of JDBC Driver 

JDBC Driver is a software module which enables java application to relate with the database. There are 4 types of JDBC drivers.

1.    Bridge driver of JDBC-ODBC

2.    Driver Native-API

3.    Driver Network Protocol

4.    Thin driver

1) JDBC-ODBC bridge driver

 

The JDBC-ODBC connect driver utilizes ODBC driver to associate with the database. The JDBC-ODBC connects driver changes over JDBC technique calls into the ODBC work calls. This is presently demoralized in light of thin driver.

Advantages:

  • Using is easy simple to utilize.
  • For connection of data base is easily associated.JDBC-ODBC Driver                                            JDBC –ODBC Bridge DriverHindrances
    • Execution corrupted in light of the fact that JDBC strategy call is changed over into the ODBC work calls.

     

    • The ODBC driver should be introduced on the customer machine.

     

    2) Native-API driver

    The Native API driver utilizes the customer side libraries of the database. The driver changes over JDBC technique calls into local calls of the database API. It is not composed completely in java.

    Advantages:

    Execution updated than JDBC-ODBC connect driver.

    Native API DriverDisadvantages:

    • The Native driver should be introduced on the every customer machine.

     

    • The Vendor customer library should be introduced on customer machine.

     

    3) Network Protocol driver

    The Network Protocol driver utilizes middle ware (application server) that proselytes JDBC calls straightforwardly or by implication into the merchant particular database convention. It is completely composed in java.

    Network Protocol Driver

     

    Advantages:

    No customer side library is required in light of use server that can perform many errands like reviewing, stack adjusting, logging and so on.

Disadvantages:

  • System bolster is required on customer machine.
  •  Requires database-particular coding to be done in the center level.
  •  Upkeep of Network Protocol driver turns out to be expensive on the grounds that it    requires database-particular coding to be done in the center level.

          4) Thin driver

The thin driver changes over JDBC calls straightforwardly into the merchant particular            database convention. That is the reason it is known as thin driver. It is completely composed in Java dialect.

Thin Driver

Advantages:

  •  Preferable execution over every other driver.
  • No product is required at customer side or server side.

 Disadvantages:

  • Drivers rely upon the Database.

 

Driver Manager:

The DriverManager example of true excellence as an interface among client and drivers. It monitors the drivers that are accessible and handles setting up an association between a database and the proper driver. The DriverManager class keeps up a rundown of Driver classes that have enlisted themselves by calling the strategy DriverManager.

 DriverManager Methods:

 

Methods of DriverManager

Connection interface:

A Connection is the session between java application and database. The Connection interface is a processing plant of Statement, Prepared Statement, and DatabaseMetaData i.e. protest of Connection can be utilized to get question of Statement and DatabaseMetaData.

The Connection interface give numerous strategies to exchange administration like submit() rollback().

Methods of Connection Interface:

 

Connection Interface

                                              

Drop Us A Query

Trending Courses
  • Python and Django Online Training
  • Python is a dynamic interrupted language which is used in wide varieties of applications. It is very interactive object oriented and high-level programming language.

  • Tableau Online Training
  • Tableau is a Software company that caters interactive data visualization products that provide Business Intelligence services. The company’s Head Quarters is in Seattle, USA.

  • MicroStrategy Online Training
  • Micro Strategy is one of the few independent and publicly trading Business Intelligence software provider in the market. The firm is operational in 27 Countries around the globe.

  • PEGA (PRPC) 7.2 Certification Online Training
  • Pega Systems Inc. is a Cambridge, Massachusetts based Software Company. It is known for developing software for Customer Relationship Management (CRM) and Business process Management (BPM).

  • Workday Online Training
  • Workday specialises in providing Human Capital Management, Financial Management and payroll in online domain.It is a major web based ERP software vendor.

  • Power BI Online Training
  • Power BI is business analytics service by Microsoft. With Power BI, end users can develop reports and dashboards without depending on IT staff or Database Administrator.


100% Secure Payments. All major credit & debit cards accepted.