Pages

Saturday, February 9, 2013

Database Connectivity using Java & Packages in Java


Database connectivity and handling the contents of the database are done using the Drivers provided by various vendors. Databases and Java language are unknown to each other and hence there is a requirement of a common mediator between java language and the database which is generally called a Driver.


Drivers provide the internal functionality of the type of database we are working on i.e., MySQL, Oracle, DB2 etc. ODBC is open database connectivity provided by Microsoft first and is used in general by all the programmers. JDBC was later introduced by Java and is used to connect to a database using Java. In my tutorials we will generally use the ODBC and Oracle to connect to the databases. This is a Type 4 driver.


The functions to connect to databases are given in two packages in java which are java.sql.* and javax.sql.*.

Interfaces and Classes in java.sql.* package :

Interfaces

  • Connection
  • Statement
  • ResultSet
  • ResultSetMetaData
  • CallableStatement
  • Driver
  • DatabaseMetaData
  • PreparedStatement
  • And Others.


Classes

  • Date
  • DriverManager - Most commonly used
  • Time
  • Types
  • And More.

I will use Type 4 Driver and connect to Oracle Database in all my tutorials.

0 comments:

Post a Comment