Driver Available Parameters

In this chapter you will learn:

  1. Get a List of all Available Parameters for Creating a JDBC Connection

List of available parameters

Driver.getPropertyInfo() returns a list of all available properties that can be supplied when using the driver to create a JDBC connection.

import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
//j  av  a2 s .  co  m
public class Main {
  public static void main(String[] args) throws Exception {

    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    Driver driver = DriverManager.getDriver(url);

    DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
    for (int i = 0; i < info.length; i++) {
      System.out.println("Name:"+info[i].name);
      System.out.println("Required:"+info[i].required);
      System.out.println("Value:"+info[i].value);
      System.out.println("Info:"+info[i].description);
      // Get possible choices for property;
      // if null, value can be any string
      String[] choices = info[i].choices;
      if (choices != null) {
        for (int c = 0; c < choices.length; c++) {
          System.out.println("Choice:"+choices[c]);
        }
      }
    }

  }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to find out the driver version
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