JDBC Examples
- JDBC Create a Table Example
- JDBC Insert Multiple Rows Example
- JDBC Update Query Example
- JDBC Select Query Example
- JDBC Delete Query Example
- JDBC Transaction Management Example
- JDBC Connection to Oracle Database Example
- JDBC Connection to PostgreSQL Example
- JDBC Connection to H2 Database Example
- Java JDBC Connection to HSQLDB Database
- Java PostgreSQL Example
- Java H2 Create Table Example
- Java H2 Insert Record Example
- Java H2 Embedded Database Example
JDBC allows a Java application to connect to a relational database.
A JDBC driver is a set of Java classes that implement the JDBC interfaces, targeting a specific database. The JDBC interfaces come with standard Java, but the implementation of these interfaces is specific to the database you need to connect to. Such an implementation is called a JDBC driver.
JDBC Driver Types
- JDBC-ODBC Bridge plus ODBC Driver (Type 1): It uses an ODBC driver to connect to the database. We should have ODBC drivers installed to connect to the database, that’s why this driver is almost obsolete.
- Native API partly Java technology-enabled driver (Type 2): This driver converts JDBC class to the client API for the database servers. We should have a database client API installed. Because of extra dependency on database client API drivers, this is also not a preferred driver.
- Pure Java Driver for Database Middleware (Type 3): This driver sends the JDBC calls to a middleware server that can connect to a different type of database. We should have a middleware server installed to work with this driver. This adds to extra network calls and slow performance and that's why not widely used JDBC driver.
- Direct-to-Database Pure Java Driver (Type 4): This driver converts the JDBC calls to the network protocol understood by the database server. This solution is simple and suitable for database connectivity over the network. However for this solution, we should use database-specific drivers, for example, JDBC jars by Oracle for Oracle DB and MySQL Connector/J for MySQL databases.
Comments
Post a Comment