Connection

In this chapter you will learn:

  1. Get to know the Connection Object
  2. Connection Object Requirements
  3. Closing JDBC connections

Connection Object

The Connection object has the following capabilities:

  • Creates SQL statements
  • Executes SQL queries, inserts, updates, and deletes
  • Handles commits and rollbacks
  • Provides metadata regarding the database connection

By default, a Connection object is in autocommit mode, which means it automatically commits changes after executing each statement.

Connection Object Requirements

Parameter Description
driverName JDBC driver
dbURL Database URL (uniquely identifies a database)
dbUsernameDatabase username
dbPassword Database user password

Closing JDBC connections

At the end of JDBC program, we have to explicitly close all the connections to the database in order to save system resource.

We can close a connection by calling the close() method associated with connection object.

conn.close();

Next chapter...

What you will learn in the next chapter:

  1. How to pass in parameters with Properties to JDBC Connection
  2. Passing 'user' and 'password' Parameters as a java.util.Properties Object to Connection object
  3. Test to See if Your Connection is Alive
Home » Java Tutorial » Driver and Connection

Introduction

    JDBC

Driver

    Driver
    Driver Loaded
    Login Timeout
    Driver Available Parameters
    Driver version
    JDBC logging

Connection

    Connection
    Connection Properties
    Connection Charset
    JDBC ODBC Bridge
    HSQL memory based database

Database Meta Data

    All key words
    Table schema
    Table catalog
    Database version
    Database product version and name
    Data type information
    Transaction level
    Connection User name, URL and driver version
    All table names
    Get all column names
    Table existance
    System Functions Supported
    Date time function
    Numeric Functions Supported
    String functions
    Feature support
    Connection Limit
    Support Scrollable ResultSet