2016-03-07 57 views
1

icc-schema.xml jdbcDatatable column中有tableTypetype屬性。icc-schema.xml的icCube定義

實施例:

列名= 「first_opened_date」 TABLETYPE = 「時間戳」 型= 「DATETIME」 選擇= 「真」 的PrimaryKey = 「假」

列名= 「prepared_food」 TABLETYPE = 「BIT」類型=選擇=「真」的PrimaryKey =「假」

我猜到tableType是指如在數據庫中定義的數據類型和type是icCube內部標識符大致與「BOOLEAN」 java.sql.Types

如果這是正確的,則可以從java.sql.Metadata.getColumns.getString("TYPE_NAME")中讀取前者[tableType],並且必須從java.sql.Metadata.getColumns.getString("DATA_TYPE")推斷後面的[type]。

我的猜測是正確的嗎?你有對應表嗎?什麼是錯誤或缺失屬性的影響?

回答

1

假設我們正在談論JDBC表。 「

表格類型「在代碼內沒有被使用;它顯示爲一個指示。 該名稱源自java.sql.Types整數,由元信息返回。

」類型「是列的實際數據類型。從DB中讀取的值將被轉換爲 爲此數據類型,然後用於構建維度和事實。這是表格UI中顯示爲 的類型,即「輸出類型」。可能的值是:

DATE  
DATETIME 
BOOLEAN 
DOUBLE 
FLOAT 
SHORT 
INTEGER 
LONG 
STRING 
UPPERCASE_STRING 
JAVA_OBJECT 
DB_TYPE_UNSUPPORTED 

映射來自java.sql.Types是如下:

DATE    from: Types.DATE 
DATETIME   from: Types.TIMESTAMP 
BOOLEAN    from: Types.BIT, Types.BOOLEAN 
DOUBLE    from: Types.FLOAT, Types.DOUBLE, Types.NUMERIC, Types.DECIMAL 
FLOAT    from: Types.REAL 
SHORT    from: Types.TINYINT, Types.SMALLINT 
INTEGER    from: Types.INTEGER 
LONG    from: Types.BIGINT, Types.ROWID 
STRING    from: Types.VARCHAR, Types.LONGVARCHAR, Types.NVARCHAR, Types.LONGNVARCHAR, Types.CHAR, Types.NCHAR 
UPPERCASE_STRING from: n/a 
JAVA_OBJECT   from: Types.JAVA_OBJECT 
DB_TYPE_UNSUPPORTED from: n/a 

希望有所幫助。

0

在補充@Polizzi的答案,以防萬一你需要它倒過來:

tableType = JDBCType.valueOf(dbtype).getName(); 
    switch(dbtype){ 
     case Types.DATE: 
      type = "DATE"; 
      break; 
     case Types.TIMESTAMP: 
      type = "DATETIME"; 
      break;    
     case Types.BIT: 
      type = "BOOLEAN"; 
      break;    
     case Types.BOOLEAN: 
      type = "BOOLEAN"; 
      break;    
     case Types.FLOAT: 
      type = "DOUBLE"; 
      break;   
     case Types.DOUBLE: 
      type = "DOUBLE"; 
      break;   
     case Types.NUMERIC: 
      type = "DOUBLE"; 
      break;    
     case Types.DECIMAL: 
      type = "DOUBLE"; 
      break;   
     case Types.REAL: 
      type = "FLOAT"; 
      break;   
     case Types.TINYINT: 
      type = "SHORT"; 
      break;   
     case Types.SMALLINT: 
      type = "SHORT"; 
      break;   
     case Types.INTEGER: 
      type = "INTEGER"; 
      break;   
     case Types.BIGINT: 
      type = "LONG"; 
      break;   
     case Types.ROWID: 
      type = "LONG"; 
      break;    
     case Types.VARCHAR: 
      type = "STRING"; 
      tableType = "VARCHAR("+length+")"; 
      break;   
     case Types.LONGVARCHAR: 
      type = "STRING"; 
      tableType = "LONGVARCHAR("+length+")"; 
      break;   
     case Types.NVARCHAR: 
      type = "STRING"; 
      tableType = "NVARCHAR("+length+")"; 
      break;    
     case Types.LONGNVARCHAR: 
      type = "STRING"; 
      tableType = "LONGVARCHAR("+length+")"; 
      break;   
     case Types.CHAR: 
      type = "STRING"; 
      tableType = "CHAR("+length+")"; 
      break;    
     case Types.NCHAR: 
      type = "STRING"; 
      tableType = "NCHAR("+length+")"; 
      break;    
     case Types.JAVA_OBJECT: 
      type = "JAVA_OBJECT"; 
      break; 
     default: 
      type = "DB_TYPE_UNSUPPORTED"; 
    }