The JDBC is used whenever a Java application should communicate with a relational database for which a JDBC driver exists. JDBC is part of the Java platform standard; all visible classes and interfaces used in the JDBC are placed in package Java

Main JDBC classes:

Download the Java connecting with Oracle Code, you have to oracle jdbc driver jar file in your project library reference or in your classpath so that you compiler can find the oracle jdbc jar file….

MyOracle.java  oracle-java-jdbc-driver.jar

  • DriverManager. Manages a list of database drivers. Matches connection requests from the java application with the proper database driver using communication subprotocol. The first driver that recognizes a certain subprotocol under jdbc will be used to establish a database Connection.
  • Driver. The database communications link, handling all communication with the database. Normally, once the driver is loaded, the developer need not call it explicitly.
  • Connection. Interface with all methods for contacting a database
  • Statement. Encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.
  • ResultSet. The answer/result from a statement. A ResultSet is a 2D list which encapsulates all outgoing results from a given SQL query.

    What is a database URL

    A database URL (or JDBC URL) is a platform independent way of addressing a database. Exact formation changes from database to database and from one type of driver to another.A database/JDBC URL is of the form

    jdbc:[subprotocol]:[node]/[databaseName] Example :

    jdbc:oracle:thin:@oracleserver:1521:oracle9i   –> to access Oracle using thin driver

    What types of JDBC drivers exist?

    There are four types of JDBC database driver:

    Driver type

    Explanation

    Comment

    1

    The JDBC/ODBC bridge driver

    A piece of native C-code that translates a JDBC call to an ODBC call. Use this driver for development, not for industrial-strength application environments. Note that you have to have an ODBC database driver manager + an ODBC database driver installed on the server in addition to the JDBC/ODBC bridge.

    2

    Native API partly java driver

    A piece of native C-code that translates a java JDBC call to a native database call level API. Use this driver for development and deployment. Due to its native code, this driver can only be used by Java Applications with full computer access (i.e. not Applets).

    3

    JDBC-Net pure Java driver

    A piece of pure java code that translates an incoming JDBC call to an outgoing database Net protocol call (such as SQL*Net). Use this driver for development and deployment. Flexible and powerful, This driver can be used by any Java component and requires only connect access to work.

    4

    Native protocol pure Java driver

    A piece of pure java code that translates an incoming JDBC call to an outgoing database native protocol call (such as Oracle CLI). Use this driver for development and deployment. This driver type is the recommended one for server-side java development.

    Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Netvouz
    • DZone
    • ThisNext
    • MisterWong
    • Wists
    • blogmarks
    • Furl
    • Reddit
    • Spurl
    • StumbleUpon
    • Technorati
    • YahooMyWeb