當前位置: 首頁>>代碼示例>>Java>>正文


Java Types.NVARCHAR屬性代碼示例

本文整理匯總了Java中java.sql.Types.NVARCHAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Types.NVARCHAR屬性的具體用法?Java Types.NVARCHAR怎麽用?Java Types.NVARCHAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.sql.Types的用法示例。


在下文中一共展示了Types.NVARCHAR屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setObject

@Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
{
    checkParameterBounds(parameterIndex);
    switch(targetSqlType)
    {
        case Types.TINYINT:
            setByte(parameterIndex, ((Byte)x).byteValue());
            break;
        case Types.SMALLINT:
            setShort(parameterIndex, ((Short)x).shortValue());
            break;
        case Types.INTEGER:
            setInt(parameterIndex, ((Integer)x).intValue());
            break;
        case Types.BIGINT:
            setLong(parameterIndex, ((Long)x).longValue());
            break;
        case Types.DOUBLE:
            setDouble(parameterIndex, ((Double)x).doubleValue());
            break;
        case Types.DECIMAL:
            setBigDecimal(parameterIndex, (BigDecimal)x);
            break;
        case Types.TIMESTAMP:
            setTimestamp(parameterIndex, (Timestamp)x);
            break;
        case Types.VARBINARY:
        case Types.VARCHAR:
        case Types.NVARCHAR:
            setString(parameterIndex, (String)x);
            break;
        default:
            throw SQLError.get(SQLError.ILLEGAL_ARGUMENT);
    }
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:36,代碼來源:JDBC4PreparedStatement.java

示例2: encoding

public static String encoding(String source, int sqlType, String sourceEncoding, String targetEncoding) {
    switch (sqlType) {
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
        case Types.LONGNVARCHAR:
        case Types.CLOB:
        case Types.NCLOB:
            if (false == StringUtils.isEmpty(source)) {
                String fromEncoding = StringUtils.isBlank(sourceEncoding) ? "UTF-8" : sourceEncoding;
                String toEncoding = StringUtils.isBlank(targetEncoding) ? "UTF-8" : targetEncoding;

                // if (false == StringUtils.equalsIgnoreCase(fromEncoding,
                // toEncoding)) {
                try {
                    return new String(source.getBytes(fromEncoding), toEncoding);
                } catch (UnsupportedEncodingException e) {
                    throw new IllegalArgumentException(e.getMessage(), e);
                }
                // }
            }
    }

    return source;
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:27,代碼來源:SqlUtils.java

示例3: isStringType

/**
 * Returns true if the given sqlType identifier is a String data type
 * @param sqlType
 * @return
 * @see java.sql.Types
 */
public static boolean isStringType(int sqlType) {
    switch (sqlType) {
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR: {
            return (true);
        }
        default:
            return (false);
    }
}
 
開發者ID:faclc4,項目名稱:HTAPBench,代碼行數:18,代碼來源:SQLUtil.java

示例4: getPseudoColumns

@Override
public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern,
		String columnNamePattern) throws SQLException
{
	String sql = "select TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, "
			+ "CASE " + "	WHEN SPANNER_TYPE = 'ARRAY' THEN " + Types.ARRAY + " "
			+ "	WHEN SPANNER_TYPE = 'BOOL' THEN " + Types.BOOLEAN + " " + "	WHEN SPANNER_TYPE = 'BYTES' THEN "
			+ Types.BINARY + " " + "	WHEN SPANNER_TYPE = 'DATE' THEN " + Types.DATE + " "
			+ "	WHEN SPANNER_TYPE = 'FLOAT64' THEN " + Types.DOUBLE + " " + "	WHEN SPANNER_TYPE = 'INT64' THEN "
			+ Types.BIGINT + " " + "	WHEN SPANNER_TYPE = 'STRING' THEN " + Types.NVARCHAR + " "
			+ "	WHEN SPANNER_TYPE = 'STRUCT' THEN " + Types.STRUCT + " "
			+ "	WHEN SPANNER_TYPE = 'TIMESTAMP' THEN " + Types.TIMESTAMP + " " + "END AS DATA_TYPE, "
			+ "0 AS COLUMN_SIZE, NULL AS DECIMAL_DIGITS, 0 AS NUM_PREC_RADIX, 'USAGE_UNKNOWN' AS COLUMN_USAGE, NULL AS REMARKS, 0 AS CHAR_OCTET_LENGTH, IS_NULLABLE "
			+ FROM_STATEMENT_WITHOUT_RESULTS;

	if (catalog != null)
		sql = sql + "AND UPPER(TABLE_CATALOG) like ? ";
	if (schemaPattern != null)
		sql = sql + "AND UPPER(TABLE_SCHEMA) like ? ";
	if (tableNamePattern != null)
		sql = sql + "AND UPPER(TABLE_NAME) like ? ";
	if (columnNamePattern != null)
		sql = sql + "AND UPPER(COLUMN_NAME) LIKE ? ";
	sql = sql + "ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION ";

	CloudSpannerPreparedStatement statement = prepareStatement(sql, catalog, schemaPattern, tableNamePattern,
			columnNamePattern);
	return statement.executeQuery();
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:29,代碼來源:CloudSpannerDatabaseMetaData.java

示例5: isCharColumn

/**
 * Determine if a column is char or a char-variant type.
 * @return true if column type is CHAR, VARCHAR, LONGVARCHAR
 * or their N version. These are used to store strings.
 */
public boolean isCharColumn(int columnType) {
  return (columnType == Types.VARCHAR)
      || (columnType == Types.NVARCHAR)
      || (columnType == Types.CHAR)
      || (columnType == Types.NCHAR)
      || (columnType == Types.LONGVARCHAR)
      || (columnType == Types.LONGNVARCHAR);
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:13,代碼來源:ConnManager.java

示例6: toHiveType

/**
 * Given JDBC SQL types coming from another database, what is the best
 * mapping to a Hive-specific type?
 */
public static String toHiveType(int sqlType) {

    switch (sqlType) {
        case Types.INTEGER:
        case Types.SMALLINT:
            return "INT";
        case Types.VARCHAR:
        case Types.CHAR:
        case Types.LONGVARCHAR:
        case Types.NVARCHAR:
        case Types.NCHAR:
        case Types.LONGNVARCHAR:
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
        case Types.CLOB:
            return "STRING";
        case Types.NUMERIC:
        case Types.DECIMAL:
        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.REAL:
            return "DOUBLE";
        case Types.BIT:
        case Types.BOOLEAN:
            return "BOOLEAN";
        case Types.TINYINT:
            return "TINYINT";
        case Types.BIGINT:
            return "BIGINT";
        default:
      // TODO(aaron): Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT,
      // BLOB, ARRAY, STRUCT, REF, JAVA_OBJECT.
      return null;
    }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:40,代碼來源:HiveTypes.java

示例7: dataTypeFromSqlType

/**
 * SqlServerDialect maps CLOB data types to NVARCHAR(MAX) but NVARCHAR sqlTypes are mapped as Strings in the {@link DatabaseMetaDataProvider}.
 * This method uses the column width to determine whether a sqlType == Type.NVARCHAR should be mapped to a String
 * or to a CLOB data type. If the column with is large (> ~ 1G) it will be mapped to a CLOB data type. Otherwise
 * is will be mapped as a String.
 *
 * @see org.alfasoftware.morf.jdbc.DatabaseMetaDataProvider#dataTypeFromSqlType(int, java.lang.String, int)
 */
@Override
protected DataType dataTypeFromSqlType(int sqlType, String typeName, int width) {
  if (sqlType == Types.NVARCHAR && width > 1<<30) {
    return DataType.CLOB;
  } else {
    return super.dataTypeFromSqlType(sqlType, typeName, width);
  }
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:16,代碼來源:SqlServerMetaDataProvider.java

示例8: 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

示例9: isCharacterData

private boolean isCharacterData(int typeCode) {
	return Types.VARCHAR == typeCode
			|| Types.CHAR == typeCode
			|| Types.NVARCHAR == typeCode
			|| Types.NCHAR == typeCode;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:LiteralNode.java

示例10: getEstimatedRowSizeInCloudSpanner

/**
 * @param connection
 *            The connection to use to estimate the row size
 * @param catalog
 *            The catalog of the table
 * @param schemaPattern
 *            The schema of the table
 * @param tableNamePattern
 *            The name of the table
 * @param columnNamePattern
 *            The name of the column(s) to check
 * @return The estimated size in bytes of one row of the specified columns
 *         of the specified table
 * @throws SQLException
 *             If a database error occurs while getting the table meta data
 */
public static int getEstimatedRowSizeInCloudSpanner(Connection connection, String catalog, String schemaPattern,
		String tableNamePattern, String columnNamePattern) throws SQLException
{
	// There's an 8 bytes storage overhead for each column
	int totalSize = 8;
	try (ResultSet rs = connection.getMetaData().getColumns(catalog, schemaPattern, tableNamePattern,
			columnNamePattern))
	{
		while (rs.next())
		{
			long colLength = rs.getLong("COLUMN_SIZE");
			int colType = rs.getInt("DATA_TYPE");
			switch (colType)
			{
			case Types.ARRAY:
				break;
			case Types.BOOLEAN:
				totalSize += 1;
				break;
			case Types.BINARY:
				totalSize += colLength;
				break;
			case Types.DATE:
				totalSize += 4;
				break;
			case Types.DOUBLE:
				totalSize += 8;
				break;
			case Types.BIGINT:
				totalSize += 8;
				break;
			case Types.NVARCHAR:
				totalSize += colLength * 2;
				break;
			case Types.TIMESTAMP:
				totalSize += 12;
				break;
			}
		}
	}
	return totalSize;
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:58,代碼來源:ConverterUtils.java

示例11: getTypeClass

protected static Class<? extends Object> getTypeClass(DBColumn col) {
    int colType = col.getJdbcType();

    if (colType == Types.BIT && col.getPrecision() <= 1) {
        colType = Types.BOOLEAN;
    }

    switch (colType) {
        case Types.BOOLEAN:
            return Boolean.class;
        case Types.TIME:
            return Time.class;
        case Types.DATE:
            return Date.class;
        case Types.TIMESTAMP:
        case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP:
        case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP_WITH_TZ:
            return Timestamp.class;
        case Types.BIGINT:
            return BigInteger.class;
        case Types.DOUBLE:
            return Double.class;
        case Types.FLOAT:
        case Types.REAL:
            return Float.class;
        case Types.DECIMAL:
        case Types.NUMERIC:
            return BigDecimal.class;
        case Types.INTEGER:
        case Types.SMALLINT:
        case Types.TINYINT:
            return Long.class;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
        case Types.ROWID:
            return String.class;

        case Types.BIT:
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case Types.BLOB:
            return Blob.class;
        case Types.LONGVARCHAR:
        case Types.LONGNVARCHAR:
        case Types.CLOB:
        case Types.NCLOB: /*NCLOB */
            return Clob.class;
        case Types.OTHER:
        default:
            return Object.class;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:56,代碼來源:ResultSetTableModel.java

示例12: getSqlTypeString

/**
 * Convert sql types to String for display
 *
 * @param sqlType the type number from java.sql.Types
 * @return the type name
 */
static public String getSqlTypeString(int sqlType) {
    switch (sqlType) {
        case Types.BIGINT:
            return "BIGINT"; //NOI18N
        case Types.BINARY:
            return "BINARY"; //NOI18N
        case Types.BIT:
            return "BIT"; //NOI18N
        case Types.NCHAR:
            return "NCHAR"; //NOI18N
        case Types.CHAR:
            return "CHAR"; //NOI18N
        case Types.DATE:
            return "DATE"; //NOI18N
        case Types.DECIMAL:
            return "DECIMAL"; //NOI18N
        case Types.DOUBLE:
            return "DOUBLE"; //NOI18N
        case Types.FLOAT:
            return "FLOAT"; //NOI18N
        case Types.INTEGER:
            return "INTEGER"; //NOI18N
        case Types.LONGVARBINARY:
            return "LONGVARBINARY"; //NOI18N
        case Types.LONGNVARCHAR:
            return "LONGNVARCHAR"; //NOI18N
        case Types.LONGVARCHAR:
            return "LONGVARCHAR"; //NOI18N
        case Types.NULL:
            return "NULL"; //NOI18N
        case Types.NUMERIC:
            return "NUMERIC"; //NOI18N
        case Types.OTHER:
            return "OTHER"; //NOI18N
        case Types.REAL:
            return "REAL"; //NOI18N
        case Types.SMALLINT:
            return "SMALLINT"; //NOI18N
        case Types.TIME:
            return "TIME"; //NOI18N
        case Types.TIMESTAMP:
            return "TIMESTAMP"; //NOI18N
        case Types.TINYINT:
            return "TINYINT"; //NOI18N
        case Types.VARBINARY:
            return "VARBINARY"; //NOI18N
        case Types.NVARCHAR:
            return "NVARCHAR";
        case Types.VARCHAR:
            return "VARCHAR"; //NOI18N
        case Types.JAVA_OBJECT:
            return "JAVA_OBJECT"; //NOI18N
        case Types.DISTINCT:
            return "DISTINCT"; //NOI18N
        case Types.STRUCT:
            return "STRUCT"; //NOI18N
        case Types.ARRAY:
            return "ARRAY"; //NOI18N
        case Types.BLOB:
            return "BLOB"; //NOI18N
        case Types.NCLOB:
            return "NCLOB";
        case Types.CLOB:
            return "CLOB"; //NOI18N
        case Types.REF:
            return "REF"; //NOI18N
        default:
            Logger.getLogger(SQLTypeUtil.class.getName()).log(Level.WARNING, "Unknown JDBC column type: {0}. Returns null.", sqlType);
            return "UNKNOWN"; //NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:77,代碼來源:SQLTypeUtil.java

示例13: getSqlType

@Override
public int getSqlType() {
	return Types.NVARCHAR;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:NVarcharTypeDescriptor.java

示例14: toHCatType

/**
 * Resolve a database-specific type to HCat data type. Largely follows Sqoop's
 * hive translation.
 * @param sqlType
 *          sql type
 * @return hcat type
 */
public static String toHCatType(int sqlType) {
  switch (sqlType) {

  // Ideally TINYINT and SMALLINT should be mapped to their
  // HCat equivalents tinyint and smallint respectively
  // But the Sqoop Java type conversion has them mapped to Integer
  // Even though the referenced Java doc clearly recommends otherwise.
  // Changing this now can cause many of the sequence file usages to
  // break as value class implementations will change. So, we
  // just use the same behavior here.
    case Types.SMALLINT:
    case Types.TINYINT:
    case Types.INTEGER:
      return "int";

    case Types.VARCHAR:
      return "varchar";
    case Types.CHAR:
      return "char";
    case Types.LONGVARCHAR:
    case Types.NVARCHAR:
    case Types.NCHAR:
    case Types.LONGNVARCHAR:
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
    case Types.CLOB:
      return "string";

    case Types.FLOAT:
    case Types.REAL:
      return "float";

    case Types.NUMERIC:
    case Types.DECIMAL:
      return "decimal";

    case Types.DOUBLE:
      return "double";

    case Types.BIT:
    case Types.BOOLEAN:
      return "boolean";

    case Types.BIGINT:
      return "bigint";

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.BLOB:
    case Types.LONGVARBINARY:
      return "binary";

    default:
      throw new IllegalArgumentException(
        "Cannot convert SQL type to HCatalog type " + sqlType);
  }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:65,代碼來源:SqoopHCatUtilities.java

示例15: 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


注:本文中的java.sql.Types.NVARCHAR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。