カラム
DatabaseMetaData インターフェースのgetColumns メソッドを使用して、カラム情報を取得できます。
結果は、テーブル名に基づいて制限できます。
次のコード例は、Lead テーブルのカラム名を取得します。
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"));
}
getColumns メソッドは次のカラムを返します。
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.
| カラム名 | データ型 | 説明 |
| TABLE_CAT | String | データベース名。 |
| TABLE_SCHEM | String | テーブルスキーマ。 |
| TABLE_NAME | String | テーブル名。 |
| COLUMN_NAME | String | カラム名。 |
| DATA_TYPE | int | java.sql.Types で定義されている定数値によって識別されるデータ型。 |
| TYPE_NAME | String | 本製品 によって使用されるデータ型名。 |
| COLUMN_SIZE | int | カラムの文字数単位の長さ、または数値精度。 |
| BUFFER_LENGTH | int | バッファ長。 |
| DECIMAL_DIGITS | int | カラムのスケール(小数点以下の桁数)。 |
| NUM_PREC_RADIX | int | 基数。 |
| NULLABLE | int | カラムに、次のJDBC DatabaseMetaData 定数で定義されているnull を含めることができるかどうか:parameterNoNulls (0) またはparameterNullable (1) 。 |
| REMARKS | String | カラムの説明。 |
| COLUMN_DEF | String | カラムのデフォルト値。 |
| SQL_DATA_TYPE | int | 仕様で予約されています。 |
| SQL_DATETIME_SUB | int | 仕様で予約されています。 |
| CHAR_OCTET_LENGTH | int | バイナリおよび文字ベースのカラムの最大長。 |
| ORDINAL_POSITION | int | 1から始まるカラムインデックス。 |
| IS_NULLABLE | String | Null 値が許可されるかどうか(YES またはNO)。 |
| SCOPE_CATALOG | String | 参照属性の範囲となるテーブルカタログ。 |
| SCOPE_SCHEMA | String | 参照属性の範囲となるテーブルスキーマ。 |
| SCOPE_TABLE | String | 参照属性の範囲となるテーブル名。 |
| SOURCE_DATA_TYPE | int | DISTINCT 型のソース型。または、ユーザー生成Ref 型。DATA_TYPE がDISTINCT でない場合、この値はnull になります。ユーザー生成Ref の場合、この値はnull になります。 |
| IS_AUTOINCREMENT | String | Microsoft Dynamics CRM によってカラムに固定増分値が割り当てられるかどうか。 |
| IS_GENERATEDCOLUMN | String | 生成されたカラムであるかどうか(YES またはNO)。 |