Ejemplo n.º 1
0
 // returns a string format of the SQL Datatype of the column using the getFieldType function from
 // DBaseFileHeader
 private static String getSQLDataType(Connection conn, DbaseFileHeader dbfHeader, int index) {
   char dataType = dbfHeader.getFieldType(index);
   String sqlDataType = "";
   if (dataType == 'C')
     sqlDataType = SQLUtils.getVarcharTypeString(conn, dbfHeader.getFieldLength(index));
   else if (dataType == 'N' || dataType == 'F') {
     // if it has not 0 decimals return type as integer else Double Precision
     if (dbfHeader.getFieldDecimalCount(index) == 0)
       sqlDataType = SQLUtils.getBigIntTypeString(conn);
     else sqlDataType = SQLUtils.getDoubleTypeString(conn);
   } else if (dataType == 'D') {
     sqlDataType = SQLUtils.getDateTimeTypeString(conn);
   } else {
     throw new RuntimeException(
         "Unknown DBF data type: " + dataType + " in column " + dbfHeader.getFieldName(index));
   }
   return sqlDataType;
 }