sourceValueMeta = new ValueMetaNone( name == null ? c.getName() : name ); sourceValueMeta.setLength( c.getLength(), c.getPrecision() );
private String getHsqldbColumnType(Column cl) throws IOException { String htype; DataType dtyp = cl.getType(); DataType rtyp = getReturnType(cl); boolean calcType = false; if (rtyp != null) { dtyp = rtyp; calcType = true; } if (dtyp.equals(DataType.TEXT)) { int ln = ff1997 ? cl.getLength() : cl.getLengthInUnits(); htype = "VARCHAR(" + ln + ")"; } else if (dtyp.equals(DataType.NUMERIC) && (cl.getScale() > 0 || calcType)) { if (calcType) { htype = "NUMERIC(100 ,4)"; } else { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + cl.getScale() + ")"; } } else if (dtyp.equals(DataType.FLOAT) && calcType) { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + 4 + ")"; } else { htype = TypesMap.map2hsqldb(dtyp); } return htype; }
case java.sql.Types.LONGVARCHAR: // Character Large Object valtype = ValueMetaInterface.TYPE_STRING; length = column.getLength(); break; case java.sql.Types.NUMERIC: valtype = ValueMetaInterface.TYPE_NUMBER; length = column.getLength(); precision = column.getPrecision(); if ( length >= 126 ) { length = column.getLength(); break;
public int getLength(Column originalColumn) { return originalColumn.getLength(); }
@Override protected Schema getMainSchema() throws MetaModelException { Schema schema = new Schema(_file.getName()); Database db = getDatabase(); for (com.healthmarketscience.jackcess.Table mdbTable : db) { Table table = new Table(mdbTable.getName(), TableType.TABLE, schema); try { int i = 0; for (com.healthmarketscience.jackcess.Column mdbColumn : mdbTable .getColumns()) { ColumnType columnType = ColumnType .convertColumnType(mdbColumn.getSQLType()); Column column = new Column(mdbColumn.getName(), columnType, table, i, null); column.setColumnSize((int) mdbColumn.getLength()); column.setNativeType(mdbColumn.getType().name()); table.addColumn(column); i++; } schema.addTable(table); } catch (Exception e) { throw new MetaModelException(e); } } return schema; }
/** * Sets all attributes except name from the given Column template (including * all column properties except GUID). */ public ColumnBuilder setFromColumn(Column template) throws IOException { DataType type = template.getType(); setType(type); setLength(template.getLength()); setAutoNumber(template.isAutoNumber()); if(type.getHasScalePrecision()) { setScale(template.getScale()); setPrecision(template.getPrecision()); } setCalculated(template.isCalculated()); setCompressedUnicode(template.isCompressedUnicode()); setHyperlink(template.isHyperlink()); if(template instanceof ColumnImpl) { setTextSortOrder(((ColumnImpl)template).getTextSortOrder()); } PropertyMap colProps = template.getProperties(); for(PropertyMap.Property colProp : colProps) { // copy everything but guid if(!PropertyMap.GUID_PROP.equalsIgnoreCase(colProp.getName())) { setProperty(colProp.getName(), colProp); } } return this; }
@Override protected Schema getMainSchema() throws MetaModelException { MutableSchema schema = new MutableSchema(_file.getName()); Database db = getDatabase(); for (com.healthmarketscience.jackcess.Table mdbTable : db) { final MutableTable table = new MutableTable(mdbTable.getName(), TableType.TABLE, schema); try { int i = 0; for (com.healthmarketscience.jackcess.Column mdbColumn : mdbTable.getColumns()) { final ColumnType columnType = ColumnType.convertColumnType(mdbColumn.getSQLType()); final MutableColumn column = new MutableColumn(mdbColumn.getName(), columnType, table, i, null); column.setColumnSize((int) mdbColumn.getLength()); column.setNativeType(mdbColumn.getType().name()); table.addColumn(column); i++; } final Index primaryKeyIndex = mdbTable.getPrimaryKeyIndex(); final List<ColumnDescriptor> columnDescriptors = primaryKeyIndex.getColumns(); for (ColumnDescriptor columnDescriptor : columnDescriptors) { final String name = columnDescriptor.getColumn().getName(); final MutableColumn column = (MutableColumn) table.getColumnByName(name); column.setPrimaryKey(true); } schema.addTable(table); } catch (Exception e) { throw new MetaModelException(e); } } return schema; }