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


Java Types.VARCHAR属性代码示例

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


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

示例1: add

/**
 * 添加一条天气记录
 * @param weather
 * @return
 */
public boolean add(Weather weather){
    Object[] params = new Object[]{weather.getCityName(), weather.getInsertDate(),
            weather.getWeather1(), weather.getWeather2(), weather.getWeather3(), weather.getWeather4(),
            weather.getWeather5(), weather.getWeather6(), weather.getWeather7(),
            weather.getMaxTemp1(), weather.getMaxTemp2(), weather.getMaxTemp3(), weather.getMaxTemp4(),
            weather.getMaxTemp5(), weather.getMaxTemp6(), weather.getMaxTemp7(),
            weather.getMinTemp1(), weather.getMinTemp2(), weather.getMinTemp3(), weather.getMinTemp4(),
            weather.getMinTemp5(), weather.getMinTemp6(), weather.getMinTemp7(),
            weather.getWind1(), weather.getWind2(), weather.getWind3(), weather.getWind4(),
            weather.getWind5(), weather.getWind6(), weather.getWind7()};

    int[] types = new int[]{Types.VARCHAR, Types.DATE,
            Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
            Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
            Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
            Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,};

    return this.jdbcTemplate.update(SQL_ADD_WEATHER, params, types) > 0;
}
 
开发者ID:MasonQAQ,项目名称:WeatherSystem,代码行数:24,代码来源:WeatherDao.java

示例2: getPseudoColumns

/**
 * JDBC-4.1
 * 
 * @param catalog
 * @param schemaPattern
 * @param tableNamePattern
 * @param columnNamePattern
 * @throws SQLException
 */
public java.sql.ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
    Field[] fields = { new Field("", "TABLE_CAT", Types.VARCHAR, 512), new Field("", "TABLE_SCHEM", Types.VARCHAR, 512),
            new Field("", "TABLE_NAME", Types.VARCHAR, 512), new Field("", "COLUMN_NAME", Types.VARCHAR, 512),
            new Field("", "DATA_TYPE", Types.INTEGER, 12), new Field("", "COLUMN_SIZE", Types.INTEGER, 12),
            new Field("", "DECIMAL_DIGITS", Types.INTEGER, 12), new Field("", "NUM_PREC_RADIX", Types.INTEGER, 12),
            new Field("", "COLUMN_USAGE", Types.VARCHAR, 512), new Field("", "REMARKS", Types.VARCHAR, 512),
            new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, 12), new Field("", "IS_NULLABLE", Types.VARCHAR, 512) };

    return buildResultSet(fields, new ArrayList<ResultSetRow>());
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:19,代码来源:DatabaseMetaData.java

示例3: isCaseSensitive

/**
 * Does a column's case matter?
 * 
 * @param column
 *            the first column is 1, the second is 2...
 * 
 * @return true if so
 * 
 * @throws java.sql.SQLException
 *             if a database access error occurs
 */
public boolean isCaseSensitive(int column) throws java.sql.SQLException {
    Field field = getField(column);

    int sqlType = field.getSQLType();

    switch (sqlType) {
        case Types.BIT:
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
        case Types.BIGINT:
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            return false;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:

            if (field.isBinary()) {
                return true;
            }

            String collationName = field.getCollation();

            return ((collationName != null) && !collationName.endsWith("_ci"));

        default:
            return true;
    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:46,代码来源:ResultSetMetaData.java

示例4: createFunctionColumnsFields

protected Field[] createFunctionColumnsFields() {
    Field[] fields = { new Field("", "FUNCTION_CAT", Types.VARCHAR, 512), new Field("", "FUNCTION_SCHEM", Types.VARCHAR, 512),
            new Field("", "FUNCTION_NAME", Types.VARCHAR, 512), new Field("", "COLUMN_NAME", Types.VARCHAR, 512),
            new Field("", "COLUMN_TYPE", Types.VARCHAR, 64), new Field("", "DATA_TYPE", Types.SMALLINT, 6), new Field("", "TYPE_NAME", Types.VARCHAR, 64),
            new Field("", "PRECISION", Types.INTEGER, 12), new Field("", "LENGTH", Types.INTEGER, 12), new Field("", "SCALE", Types.SMALLINT, 12),
            new Field("", "RADIX", Types.SMALLINT, 6), new Field("", "NULLABLE", Types.SMALLINT, 6), new Field("", "REMARKS", Types.VARCHAR, 512),
            new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, 32), new Field("", "ORDINAL_POSITION", Types.INTEGER, 32),
            new Field("", "IS_NULLABLE", Types.VARCHAR, 12), new Field("", "SPECIFIC_NAME", Types.VARCHAR, 64) };
    return fields;
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:10,代码来源:DatabaseMetaData.java

示例5: getColumnType

public int getColumnType( int index ) throws OdaException
{
	//return Types.JAVA_OBJECT;//Any OrientDB field may be NULL
	///*
	String fieldName = getColumnName(index);
	OType fieldType = rowDoc.fieldType(fieldName);
	if (fieldType!=null){
		return typesSqlTypes.get(fieldType);
	}else{
		return Types.VARCHAR;
		//throw new OdaException("Unknown OType of field "+fieldName+" with index "+index);
	}
	//*/
}
 
开发者ID:OrienteerBAP,项目名称:orientdb-oda-birt,代码行数:14,代码来源:ResultSetMetaData.java

示例6: setupForUtf8StringInBlob

private void setupForUtf8StringInBlob() {
    if (this.length == MysqlDefs.LENGTH_TINYBLOB || this.length == MysqlDefs.LENGTH_BLOB) {
        this.mysqlType = MysqlDefs.FIELD_TYPE_VARCHAR;
        this.sqlType = Types.VARCHAR;
    } else {
        this.mysqlType = MysqlDefs.FIELD_TYPE_VAR_STRING;
        this.sqlType = Types.LONGVARCHAR;
    }

    this.collationIndex = CharsetMapping.MYSQL_COLLATION_INDEX_utf8;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:11,代码来源:Field.java

示例7: convertFromType

int convertFromType(int type) {

        // MS SQL 7 specific problems (Northwind database)
        if (type == 11) {
            tracer.trace("Converted DATETIME (type 11) to TIMESTAMP");

            type = Types.TIMESTAMP;
        } else if (type == -9) {
            tracer.trace("Converted NVARCHAR (type -9) to VARCHAR");

            type = Types.VARCHAR;
        } else if (type == -8) {
            tracer.trace("Converted NCHAR (type -8) to VARCHAR");

            type = Types.VARCHAR;
        } else if (type == -10) {
            tracer.trace("Converted NTEXT (type -10) to VARCHAR");

            type = Types.VARCHAR;
        } else if (type == -1) {
            tracer.trace("Converted LONGTEXT (type -1) to LONGVARCHAR");

            type = Types.LONGVARCHAR;
        }

        return (type);
    }
 
开发者ID:s-store,项目名称:s-store,代码行数:27,代码来源:SqlServerTransferHelper.java

示例8: find

/**
 * 根据用户名和密码查询用户
 * @param username
 * @param password
 * @return
 */
public User find(String username, String password){
    Object[] params = new Object[]{username, password};
    int[] types = new int[]{Types.VARCHAR, Types.VARCHAR};
    List<User> users = this.jdbcTemplate.query(SQL_FIND_USER_BY_USERNAME_AND_PASSWORD, params, types, new UserRowMapper());
    return users.isEmpty()?null:users.get(0);
}
 
开发者ID:MasonQAQ,项目名称:WeatherSystem,代码行数:12,代码来源:UserDao.java

示例9: getSelectClauseNullString

@Override
public String getSelectClauseNullString(int sqlType) {
	String v = "null";

	switch ( sqlType ) {
		case Types.BIT:
		case Types.TINYINT:
		case Types.SMALLINT:
		case Types.INTEGER:
		case Types.BIGINT:
		case Types.FLOAT:
		case Types.REAL:
		case Types.DOUBLE:
		case Types.NUMERIC:
		case Types.DECIMAL:
			v = "cast(null as decimal)";
			break;
		case Types.CHAR:
		case Types.VARCHAR:
		case Types.LONGVARCHAR:
			v = "cast(null as varchar(255))";
			break;
		case Types.DATE:
		case Types.TIME:
		case Types.TIMESTAMP:
			v = "cast(null as timestamp)";
			break;
		case Types.BINARY:
		case Types.VARBINARY:
		case Types.LONGVARBINARY:
		case Types.NULL:
		case Types.OTHER:
		case Types.JAVA_OBJECT:
		case Types.DISTINCT:
		case Types.STRUCT:
		case Types.ARRAY:
		case Types.BLOB:
		case Types.CLOB:
		case Types.REF:
		case Types.DATALINK:
		case Types.BOOLEAN:
			break;
		default:
			break;
	}
	return v;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:TeradataDialect.java

示例10: getSchemas

/**
 * @param catalog
 * @param schemaPattern
 * @throws SQLException
 */
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
    Field[] fields = { new Field("", "TABLE_SCHEM", Types.VARCHAR, 255), new Field("", "TABLE_CATALOG", Types.VARCHAR, 255) };

    return buildResultSet(fields, new ArrayList<ResultSetRow>());
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:10,代码来源:DatabaseMetaData.java

示例11: getParameterJavaClass

static public Class<?> getParameterJavaClass(int param_type) {
	switch (param_type) {
    	case Types.ARRAY: 
    		return Object[].class; 
        case Types.BIGINT: 
        	return Long.class; 
        case Types.BINARY: 
        	return byte[].class; 
        case Types.BIT: 
        	return Boolean.class; 
        case Types.BLOB: 
        	return java.sql.Blob.class; 
        case Types.BOOLEAN:
        	return Boolean.class; 
        case Types.CHAR: 
        	return String.class; 
        case Types.CLOB: 
        	return java.sql.Clob.class; 
        case Types.DATALINK: 
        	return java.net.URL.class; 
        case Types.DATE: 
        	return java.sql.Date.class; 
        case Types.DECIMAL: 
        	return java.math.BigDecimal.class; 
        case Types.DISTINCT: 
        	return Object.class; 
        case Types.DOUBLE: 
        	return Double.class; 
        case Types.FLOAT: 
        	return Double.class; 
        case Types.INTEGER: 
        	return Integer.class; 
        case Types.JAVA_OBJECT: 
        	return Object.class; 
        case Types.LONGVARBINARY: 
        	return byte[].class; 
        case Types.LONGVARCHAR: 
        	return String.class; 
        case Types.NCLOB: 
        	return java.sql.NClob.class; 
        case Types.NULL: 
        	return Object.class; 
        case Types.NUMERIC: 
        	return java.math.BigDecimal.class; 
        case Types.NCHAR: 
        case Types.NVARCHAR: 
        case Types.LONGNVARCHAR: 
        	return String.class; 
        case Types.OTHER: 
        	return Object.class; 
        case Types.REAL: 
        	return Float.class; 
        case Types.REF: 
        	return java.sql.Ref.class; 
        case Types.ROWID: 
        	return java.sql.RowId.class; 
        case Types.SMALLINT: 
        	return Short.class; 
        case Types.STRUCT: 
        	return java.sql.Struct.class; 
        case Types.SQLXML: 
        	return java.sql.SQLXML.class; 
        case Types.TIME: 
        	return java.sql.Time.class; 
        case Types.TIMESTAMP: 
        	return java.sql.Timestamp.class; 
        case Types.TINYINT: 
        	return Byte.class; 
        case Types.VARBINARY: 
        	return byte[].class; 
        case Types.VARCHAR: 
        	return String.class; 
        default: 
        	return Object.class;
       }
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:76,代码来源:SqlConnector.java

示例12: isJdbcCharacterColumn

public boolean isJdbcCharacterColumn() {
    return jdbcType == Types.CHAR || jdbcType == Types.CLOB
            || jdbcType == Types.LONGVARCHAR || jdbcType == Types.VARCHAR
            || jdbcType == Types.LONGNVARCHAR || jdbcType == Types.NCHAR
            || jdbcType == Types.NCLOB || jdbcType == Types.NVARCHAR;
}
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:6,代码来源:IntrospectedColumn.java

示例13: test_mysql

@Test(expectedExceptions = RuntimeException.class)
public void test_mysql() {
    DbMediaSource dbMediaSource = new DbMediaSource();
    dbMediaSource.setId(10L);
    dbMediaSource.setDriver("com.mysql.jdbc.Driver");
    dbMediaSource.setUsername("xxxxx");
    dbMediaSource.setPassword("xxxxx");
    dbMediaSource.setUrl("jdbc:mysql://127.0.0.1:3306");
    dbMediaSource.setEncode("UTF-8");
    dbMediaSource.setType(DataMediaType.MYSQL);

    final DbDialect dbDialect = dbDialectFactory.getDbDialect(2L, dbMediaSource);
    want.object(dbDialect).clazIs(MysqlDialect.class);

    Table table = dbDialect.findTable("test", "ljh_demo");
    System.out.println(table);

    final SqlTemplate sqlTemplate = dbDialect.getSqlTemplate();
    final JdbcTemplate jdbcTemplate = dbDialect.getJdbcTemplate();
    final TransactionTemplate transactionTemplate = dbDialect.getTransactionTemplate();
    final int[] pkColumnTypes = { Types.INTEGER };
    final int[] columnTypes = { Types.VARCHAR, Types.INTEGER, Types.DECIMAL, Types.BIGINT };
    transactionTemplate.execute(new TransactionCallback() {

        public Object doInTransaction(TransactionStatus status) {
            int affect = 0;
            String sql = null;
            // 执行insert
            sql = sqlTemplate.getInsertSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns);
            System.out.println(sql);
            affect = (Integer) jdbcTemplate.execute(sql, new PreparedStatementCallback() {

                public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
                    doPreparedStatement(ps, dbDialect, toTypes(columnTypes, pkColumnTypes),
                                        toValues(columnValues, pkColumnValues));
                    return ps.executeUpdate();
                }

            });
            want.number(affect).isEqualTo(1);
            throw new RuntimeException("rollback");
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:45,代码来源:DbDialectIntegration.java

示例14: getSqlType

@Override
public int getSqlType() {
	return Types.VARCHAR;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:VarcharTypeDescriptor.java

示例15: sqlTypeString

public static String sqlTypeString(int sqlType) {
  switch (sqlType) {
    case Types.BIT:
      return "BIT";
    case Types.TINYINT:
      return "TINYINT";
    case Types.SMALLINT:
      return "SMALLINT";
    case Types.INTEGER:
      return "INTEGER";
    case Types.BIGINT:
      return "BIGINT";
    case Types.FLOAT:
      return "FLOAT";
    case Types.REAL:
      return "REAL";
    case Types.DOUBLE:
      return "DOUBLE";
    case Types.NUMERIC:
      return "NUMERIC";
    case Types.DECIMAL:
      return "DECIMAL";
    case Types.CHAR:
      return "CHAR";
    case Types.VARCHAR:
      return "VARCHAR";
    case Types.LONGVARCHAR:
      return "LONGVARCHAR";
    case Types.DATE:
      return "DATE";
    case Types.TIME:
      return "TIME";
    case Types.TIMESTAMP:
      return "TIMESTAMP";
    case Types.BINARY:
      return "BINARY";
    case Types.VARBINARY:
      return "VARBINARY";
    case Types.LONGVARBINARY:
      return "LONGVARBINARY";
    case Types.NULL:
      return "NULL";
    case Types.OTHER:
      return "OTHER";
    case Types.JAVA_OBJECT:
      return "JAVA_OBJECT";
    case Types.DISTINCT:
      return "DISTINCT";
    case Types.STRUCT:
      return "STRUCT";
    case Types.ARRAY:
      return "ARRAY";
    case Types.BLOB:
      return "BLOB";
    case Types.CLOB:
      return "CLOB";
    case Types.REF:
      return "REF";
    case Types.DATALINK:
      return "DATALINK";
    case Types.BOOLEAN:
      return "BOOLEAN";
    case Types.ROWID:
      return "ROWID";
    case Types.NCHAR:
      return "NCHAR";
    case Types.NVARCHAR:
      return "NVARCHAR";
    case Types.LONGNVARCHAR:
      return "LONGNVARCHAR";
    case Types.NCLOB:
      return "NCLOB";
    case Types.SQLXML:
      return "SQLXML";
    default:
      return "<UNKNOWN>";
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:78,代码来源:SqoopHCatUtilities.java


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