当前位置: 首页>>代码示例>>Java>>正文


Java Column.isAutoNumber方法代码示例

本文整理汇总了Java中com.healthmarketscience.jackcess.Column.isAutoNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Column.isAutoNumber方法的具体用法?Java Column.isAutoNumber怎么用?Java Column.isAutoNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.healthmarketscience.jackcess.Column的用法示例。


在下文中一共展示了Column.isAutoNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ComplexColumnInfoImpl

import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
protected ComplexColumnInfoImpl(Column column, int complexTypeId,
                                Table typeObjTable, Table flatTable)
  throws IOException
{
  _column = column;
  _complexTypeId = complexTypeId;
  _flatTable = flatTable;
  
  // the flat table has all the "value" columns and 2 extra columns, a
  // primary key for each row, and a LONG value which is essentially a
  // foreign key to the main table.
  List<Column> typeCols = new ArrayList<Column>();
  List<Column> otherCols = new ArrayList<Column>();
  diffFlatColumns(typeObjTable, flatTable, typeCols, otherCols);

  _typeCols = Collections.unmodifiableList(typeCols);

  Column pkCol = null;
  Column complexValFkCol = null;
  for(Column col : otherCols) {
    if(col.isAutoNumber()) {
      pkCol = col;
    } else if(col.getType() == DataType.LONG) {
      complexValFkCol = col;
    }
  }

  if((pkCol == null) || (complexValFkCol == null)) {
    throw new IOException("Could not find expected columns in flat table " +
                          flatTable.getName() + " for complex column with id "
                          + complexTypeId);
  }
  _pkCol = pkCol;
  _complexValFkCol = complexValFkCol;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:36,代码来源:ComplexColumnInfoImpl.java

示例2: AutoNumberAction

import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
public AutoNumberAction(Table table, Object[] memento,Object[] byAccess) throws SQLException {
	super();
	this.table = table;
	int i = 0;
	PreparedStatement ps = null;
	for (Column cl : table.getColumns()) {
		if (cl.isAutoNumber()) {
			UcanaccessConnection conn = UcanaccessConnection
					.getCtxConnection();
			Connection connHsqldb = conn.getHSQLDBConnection();
			String cn = SQLConverter.escapeIdentifier(cl.getName());
			Object cnOld = memento[i];
			Object cnNew = byAccess[i];
			oldAutoValues.put(cl.getName(), cnOld);
			newAutoValues.put(cl.getName(), cnNew);
			try {
				conn.setFeedbackState(true);
				String stmt = "UPDATE "
						+ SQLConverter.escapeIdentifier(table.getName())
						+ " SET " + cn + "=? WHERE " + cn + "=?";
				ps = connHsqldb.prepareStatement(stmt);
				ps.setObject(1, cnNew);
				ps.setObject(2, cnOld);
				ps.executeUpdate();
				UcanaccessConnection.getCtxConnection()
						.setFeedbackState(false);
			} finally {
				if (ps != null)
					ps.close();
			}
		}
		++i;
	}
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:35,代码来源:AutoNumberAction.java

示例3: hasAutoNumberColumn

import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
private static boolean hasAutoNumberColumn(Table t) {
	List<? extends Column> lc = t.getColumns();
	for (Column cl : lc) {
		if (cl.isAutoNumber()) {
			return true;
		}
	}
	return false;
}
 
开发者ID:andrew-nguyen,项目名称:ucanaccess,代码行数:10,代码来源:LoadJet.java

示例4: createTable

import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
private boolean createTable(Table table) {
    final String methodName = "createTable";
    StrBuilder sql = new StrBuilder();
    sql.append(String.format("CREATE TABLE %s (", table.getName()));
    
    boolean isFirst = true;
    
    for(Column column : table.getColumns()) {
        String name = column.getName();
        String type = column.getType().toString().toUpperCase();
        //short length = column.getLength();
        
        if(!isFirst)
            sql.appendln(",");
        else
            isFirst = false;
        
        switch(type) {
            case "BYTE":
            case "INT":
            case "LONG":
                if(column.isAutoNumber()) {
                    sql.append(String.format("%s INTEGER PRIMARY KEY AUTOINCREMENT", name));
                } else {
                    sql.append(String.format("%s INT NOT NULL DEFAULT 0", name));
                }
                break;
            case "FLOAT":
                sql.append(String.format("%s FLOAT NOT NULL DEFAULT 0", name));
                break;
            case "DOUBLE":
                sql.append(String.format("%s DOUBLE NOT NULL DEFAULT 0", name));
                break;
            case "NUMERIC":
                sql.append(String.format("%s DECIMAL(28,0) NOT NULL DEFAULT 0", name));
                break;
            case "MONEY":
                sql.append(String.format("%s DECIMAL(15,4) NOT NULL DEFAULT 0", name));
                break;
            case "BOOLEAN":
                sql.append(String.format("%s TINYINT NOT NULL DEFAULT 0", name));
                break;
            case "SHORT_DATE_TIME":
                sql.append(String.format("%s DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'", name));
                break;
            case "MEMO":
                sql.append(String.format("%s TEXT", name));
                break;
            case "GUID":
                sql.append(String.format("%s VARCHAR(50) DEFAULT '{00000000-0000-0000-0000-000000000000}'", name));
                break;
            case "TEXT":
            default:
                sql.append(String.format("%s VARCHAR(255) DEFAULT ''", name));
                break;
        }
    }
    
    sql.append(")");
    
    try {
        try (Statement statement = connection.createStatement()) {
            statement.executeUpdate(sql.build());
        }
        return true;
    } catch (SQLException e) {
        //lastError.add(String.format("Could not create table '%s'", table.getName()));
        //AccessConverter.Error(String.format("Could not create table '%s'", table.getName()));
        Error(String.format("Could not create table '%s'", table.getName()), e, methodName);
        return false;
    }
}
 
开发者ID:clytras,项目名称:AccessConverter,代码行数:73,代码来源:SQLiteConverter.java

示例5: fillSQLType

import com.healthmarketscience.jackcess.Column; //导入方法依赖的package包/类
private void fillSQLType( ColumnDefinition myCol, Column col )
			throws SQLException
	{
		String name = col.getType().name();
		int type = col.getSQLType();
		switch( type )
		{
			case Types.DOUBLE:
				{
					if( col.getPrecision() == 0 )
					{
						String lowerName = col.getName().toLowerCase();
						if( lowerName.endsWith( "_id" ) || lowerName.endsWith( "_lnk" )  )
						{
							type = Types.INTEGER;
							name = "integer";
						}
					}
		//			System.out.println( "double col: " + table.getName() + "." + myCol.name
		//					+ " sqlType: " + col.getSQLType() + " precision: " + col.getPrecision()
		//					+ " scale: " + col.getScale() + " varLen: " + col.isVariableLength() + " idx:" + col.getColumnIndex() );
				}
				break;
			case Types.VARCHAR:
				name = "varchar";
				break;
			case Types.TIMESTAMP:
				name = "timestamp";
				break;
			case Types.INTEGER:
				if( col.isAutoNumber() )
				{
					name = "serial";
				}
				break;
			case Types.LONGVARCHAR:
				name = "longvarchar";
				break;
		}
/*		if( "memo".equals( name.toLowerCase() ) )
		{
			System.out.println( "memo TYPE: " + type );
			name = "text";
		}*/
		
		myCol.sqlType = type;
		myCol.sqlTypeName = name;
	}
 
开发者ID:evolute-pt,项目名称:dbtransfer,代码行数:49,代码来源:TableDefinition.java


注:本文中的com.healthmarketscience.jackcess.Column.isAutoNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。