Implementations of the DataSource Interface

This section provides a summary of implementations of the DataSource interface by different JDBC drivers.

JDBC is recommending that the DataSource interface should be used to create database connection objects instead of using the DriverManager class. Many JDBC drivers have provided implementations of the DataSource interfaces. A quick summary of various implementations of the DataSource interface is provided here as a comparison and a reference:

Driver Name: Apache Derby Network Client JDBC Driver
------------
Driver JAR File: derbyclient.jar
DataSource Class: org.apache.derby.client.BasicClientDataSource
DataSource Example:
  BasicClientDataSource ds = new BasicClientDataSource();
  ds.setServerName("localhost");
  ds.setPortNumber(1527);
  ds.setDatabaseName("TestDB");
  Connection con = ds.getConnection();

Driver Name: JDBC-ODBC Bridge
------------
Driver JAR File: None (included in Java SE 1.6)
DataSource Class: sun.jdbc.odbc.ee.DataSource
DataSource Example:
  DataSource ds = new DataSource();
  ds.setDatabaseName("HY_ACCESS");

Driver Name: MySQL Connector/J
------------
Driver JAR File: mysql-connector-java-8.0.27.jar
DataSource Class: com.mysql.cj.jdbc.MysqlDataSource
DataSource Example:
  MysqlDataSource ds = new MysqlDataSource();
  ds.setServerName("localhost");
  ds.setPortNumber(3306);
  ds.setDatabaseName("HerongDB");
  ds.setUser("Herong");
  ds.setPassword("TopSecret");
  Connection con = ds.getConnection();

Driver Name: Oracle JDBC Thin client-side driver
------------
Driver JAR File: ojdbc6.jar
DataSource Class: oracle.jdbc.pool.OracleDataSource
DataSource Example:
  OracleDataSource ds = new OracleDataSource();
  ds.setDriverType("thin");
  ds.setServerName("localhost");
  ds.setPortNumber(1521);
  ds.setDatabaseName("XE"); // Oracle SID
  ds.setUser("Herong");
  ds.setPassword("TopSecret");
  Connection con = ds.getConnection();

Driver Name: Miscrosoft JDBC Driver
------------
Driver JAR File: mssql-jdbc-7.4.1.jre12.jar
DataSource Class: com.microsoft.sqlserver.jdbc.SQLServerDataSource
DataSource Example:
  SQLServerDataSource  ds = new SQLServerDataSource();
  ds.setServerName("localhost");
  ds.setPortNumber(1269);
  ds.setDatabaseName("AdventureWorksLT");
  ds.setUser("sa");
  Connection con = ds.getConnection();

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

 JDK (Java SE) Installation

 Installing and Running Java DB - Derby

 Derby (Java DB) JDBC Driver

 Derby (Java DB) JDBC DataSource Objects

 Java DB (Derby) - DML Statements

 Java DB (Derby) - ResultSet Objects of Queries

 Java DB (Derby) - PreparedStatement

Summary of JDBC Drivers and Database Servers

 List of Tested JDBC Drivers

 Connection URL Formats and Examples

Implementations of the DataSource Interface

 Performances on Inserting Rows

 Using Connection Pool with JDBC

 Archived Tutorials

 References

 Full Version in PDF/EPUB