Columns
You can use the getColumns method of the DatabaseMetaData interface to retrieve column information.
You can restrict the results by the table name.
The code example below retrieves the column names for the Lead table:
String connectionString = "jdbc:dynamicscrm:User=myuseraccount;Password=mypassword;URL=https://myOrg.crm.dynamics.com/;CRM Version=CRM Online;";
Connection conn = DriverManager.getConnection(connectionString);
DatabaseMetaData table_meta = conn.getMetaData();
ResultSet rs = table_meta.getColumns(null,null,"Lead", null);
while(rs.next()){
System.out.println(rs.getString("COLUMN_NAME"));
}
The getColumns method returns the following columns:
By default, the driver introduces a generic column named Id for each table to provide a consistent reference to the entity's primary key across the schema. This alias corresponds to the actual primary key field in the Microsoft Dynamics CRM system.
If you prefer to work with the original schema-defined names, set UseSchemaNames to True in your connection string. This exposes fields using their API names (for example, ContactId). Alternatively, if you enable UseDisplayNames, the columns display using their user-friendly names as defined in the CRM UI (for example, Contact).
NOTE: Only one of these options can be used at a time, as UseSchemaNames and UseDisplayNames are mutually exclusive.
| Column Name | Data Type | Description |
| TABLE_CAT | String | The database name. |
| TABLE_SCHEM | String | The table schema. |
| TABLE_NAME | String | The table name. |
| COLUMN_NAME | String | The column name. |
| DATA_TYPE | int | The data type identified by the value of a constant defined in java.sql.Types. |
| TYPE_NAME | String | The data type name used by the driver. |
| COLUMN_SIZE | int | The length in characters of the column or the numeric precision. |
| BUFFER_LENGTH | int | The buffer length. |
| DECIMAL_DIGITS | int | The column scale or number of digits to the right of the decimal point. |
| NUM_PREC_RADIX | int | The radix, or base. |
| NULLABLE | int | Whether the column can contain null as defined by the following JDBC DatabaseMetaData constants: columnNoNulls (0) or columnNullable (1). |
| REMARKS | String | The column description. |
| COLUMN_DEF | String | The default value for the column. |
| SQL_DATA_TYPE | int | Reserved by the specification. |
| SQL_DATETIME_SUB | int | Reserved by the specification. |
| CHAR_OCTET_LENGTH | int | The maximum length of binary and character-based columns. |
| ORDINAL_POSITION | int | The column index, starting at 1. |
| IS_NULLABLE | String | Whether a null value is allowed: YES or NO. |
| SCOPE_CATALOG | String | The table catalog that is the scope of a reference attribute. |
| SCOPE_SCHEMA | String | The table schema that is the scope of a reference attribute. |
| SCOPE_TABLE | String | The table name that is the scope of a reference attribute. |
| SOURCE_DATA_TYPE | int | The source type of a distinct type. Or, a user-generated Ref type. If DATA_TYPE is not DISTINCT, this value is null. If a user-generated Ref, this value is null. |
| IS_AUTOINCREMENT | String | Whether the column value is assigned by Microsoft Dynamics CRM in fixed increments. |
| IS_GENERATEDCOLUMN | String | Whether the column is generated: YES or NO. |