JDBC Tutorials - Herong's Tutorial Examples - v3.14, by Herong Yang
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: ojdbc11.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-9.4.1.jre16.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
JDBC (Java Database Connectivity) Introduction
Installing and Running Derby (Java DB)
Derby (Java DB) JDBC DataSource Objects
Derby (Java DB) - DML Statements
Derby (Java DB) - ResultSet Objects of Queries
Derby (Java DB) - PreparedStatement
►Summary of JDBC Drivers and Database Servers
Connection URL Formats and Examples
►Implementations of the DataSource Interface
Performances on Inserting Rows