Retrieves a description of all the standard SQL types that are supported by the current database.

public java.sql.ResultSet getTypeInfo()

Return Value

A SQLServerResultSet object.

Exceptions

SQLServerException

Remarks

This getTypeInfo method is specified by the getTypeInfo method in the java.sql.DatabaseMetaData interface.

The result set returned by the getTypeInfo method will contain the following information:

Name Type Description

TYPE_NAME

string

The name of the data type.

DATA_TYPE

short

The SQL data type from java.sql.Types.

PRECISION

integer

The total number of significant digits.

LITERAL_PREFIX

string

The character or characters used before a constant.

LITERAL_SUFFIX

string

The character or characters used to terminate a constant.

CREATE_PARAMS

string

The description of the creation parameters for the data type.

NULLABLE

short

Indicates if the column can contain a null value. It can be one of the following values:

typeNoNulls (0)

typeNullable (1)

typeNullableUnknown (2)

CASE_SENSITIVE

boolean

Indicates if the data type is case sensitive. "True" if the type is case sensitive; otherwise, "false."

SEARCHABLE

short

Indicates if the column can be used in a SQL WHERE clause. It can be one of the following values:

typePredNone (0)

typePredChar (1)

typePredBasic (2)

typeSeachable (3)

UNSIGNED_ATTRIBUTE

boolean

Indicates the sign of the data type. "True" if the type is unsigned; otherwise, "false."

FIXED_PREC_SCALE

boolean

Indicates that the data type can be a money value. "True" if the data type is money type; otherwise, "false."

AUTO_INCREMENT

boolean

Indicates that the data type can be automatically incremented. "True" if the type can be auto incremented; otherwise, "false."

LOCAL_TYPE_NAME

string

The localized name of the data type.

MINIMUM_SCALE

short

The maximum number of digits to the right of the decimal point.

MAXIMUM_SCALE

short

The minimum number of digits to the right of the decimal point.

SQL_DATA_TYPE

integer

Not supported by the JDBC driver.

SQL_DATETIME_SUB

integer

Not supported by the JDBC driver.

NUM_PREC_RADIX

integer

The number of bits or digits for calculating the maximum number that a column can hold.

Note: For more information about the data returned by the getTypeInfo method, see "sp_datatype_info (Transact-SQL)" in SQL Server Books Online.

Example

The following example demonstrates how to use the getTypeInfo method to return information about the data types used in a SQL Server 2005 database.

public static void executeGetTypeInfo(Connection con) {
   try {
      DatabaseMetaData dbmd = con.getMetaData();
      ResultSet rs = dbmd.getTypeInfo();
      ResultSetMetaData rsmd = rs.getMetaData();

      // Display the result set data.
      int cols = rsmd.getColumnCount();
      while(rs.next()) {
         for (int i = 1; i <= cols; i++) {
            System.out.println(rs.getString(i));
         }
      }
      rs.close();
   } 

   catch (Exception e) {
      e.printStackTrace();
   }
}

See Also