DriverManager - Connection URL

This section provides information about connection URL used by DriverManager to create a database connection.

As we learned earlier, the traditional way to create a connection object is to use the DriverManager class with a connection URL in the following format:

jdbc:<subprotocol>:<subname>

<subprotocol> in the URL is used to identify the JDBC driver class which will create a connection object based on information provided in <subname>. For example, "odbc" in the connection URL "jdbc:odbc:HY_FLAT" identifies the JDBC-ODBC Bridge driver. "sqlserver" in "jdbc:sqlserver://localhost:1269" identifies the Microsoft JDBC Driver.

<subname> in the URL is used to provide additional information to help the JDBC driver to identify the database server. If the database server is on remote host on the Internet, <subname> should have the following format:

jdbc:<subprotocol>://<hostname>:port<subname>

For example, "HY_FLAT" in the connection URL "jdbc:odbc:HY_FLAT" provides the data source name to help JDBC-ODBC Bridge driver to create a connection object. "//localhost:1269" in "jdbc:sqlserver://localhost:1269" provides the host name and the port number to help Microsoft JDBC Driver to create a connection object.

The DriverManager class offers 3 methods for you to create a connection object using the specified connection URL:

Connection con = DriverManager.getConnection(String url);

Connection con = DriverManager.getConnection(String url, 
  Properties info) 

Connection con = DriverManager.getConnection(String url, 
  String user, String password) 

Tutorials of using connection URLs are included in other tutorials in this book.

Last update: 2015.

Table of Contents

 About This Book

JDBC (Java Database Connectivity) Introduction

 What Is JDBC?

 JDBC Version and History

 JDBC Driver Types

 Establishing Connections from JDBC to Databases

 DriverManager - Loading JDBC Driver

DriverManager - Connection URL

 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

 MySQL Installation on Windows

 MySQL JDBC Driver (MySQL Connector/J)

 MySQL - PreparedStatement

 MySQL - Reference Implementation of JdbcRowSet

 MySQL - JBDC CallableStatement

 MySQL CLOB (Character Large Object) - TEXT

 MySQL BLOB (Binary Large Object) - BLOB

 Oracle Express Edition Installation on Windows

 Oracle JDBC Drivers

 Oracle - Reference Implementation of JdbcRowSet

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Microsoft SQL Server 2005 Express Edition

 Microsoft JDBC Driver for SQL Server - sqljdbc42.jar

 Microsoft JDBC Driver - Query Statements and Result Sets

 Microsoft JDBC Driver - DatabaseMetaData Object

 Microsoft JDBC Driver - DDL Statements

 Microsoft JDBC Driver - DML Statements

 SQL Server - PreparedStatement

 SQL Server CLOB (Character Large Object) - TEXT

 SQL Server BLOB (Binary Large Object) - BLOB

 JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver

 JDBC-ODBC Bridge Driver - Flat Text Files

 JDBC-ODBC Bridge Driver - MS Access

 JDBC-ODBC Bridge Driver - MS SQL Server

 Summary of JDBC Drivers and Database Servers

 Additional Tutorial Notes to Be Added

 Outdated Tutorials

 References

 PDF Printing Version