本文整理汇总了Java中java.sql.Types.ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java Types.ARRAY属性的具体用法?Java Types.ARRAY怎么用?Java Types.ARRAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.ARRAY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnDisplaySize
@Override
public int getColumnDisplaySize(int column) throws SQLException
{
int colType = getColumnType(column);
switch (colType)
{
case Types.ARRAY:
return 50;
case Types.BOOLEAN:
return 5;
case Types.BINARY:
return 50;
case Types.DATE:
return 10;
case Types.DOUBLE:
return 14;
case Types.BIGINT:
return 10;
case Types.NVARCHAR:
return 50;
case Types.TIMESTAMP:
return 16;
}
return 10;
}
示例2: extractColumnType
public static int extractColumnType(Type type)
{
if (type.equals(Type.bool()))
return Types.BOOLEAN;
if (type.equals(Type.bytes()))
return Types.BINARY;
if (type.equals(Type.date()))
return Types.DATE;
if (type.equals(Type.float64()))
return Types.DOUBLE;
if (type.equals(Type.int64()))
return Types.BIGINT;
if (type.equals(Type.string()))
return Types.NVARCHAR;
if (type.equals(Type.timestamp()))
return Types.TIMESTAMP;
if (type.getCode() == Code.ARRAY)
return Types.ARRAY;
return Types.OTHER;
}
示例3: getGoogleTypeName
public static String getGoogleTypeName(int sqlType)
{
if (sqlType == Types.BOOLEAN)
return Type.bool().getCode().name();
if (sqlType == Types.BINARY)
return Type.bytes().getCode().name();
if (sqlType == Types.DATE)
return Type.date().getCode().name();
if (sqlType == Types.DOUBLE || sqlType == Types.FLOAT || sqlType == Types.DECIMAL)
return Type.float64().getCode().name();
if (sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.TINYINT)
return Type.int64().getCode().name();
if (sqlType == Types.NVARCHAR)
return Type.string().getCode().name();
if (sqlType == Types.TIMESTAMP)
return Type.timestamp().getCode().name();
if (sqlType == Types.ARRAY)
return Code.ARRAY.name();
return "Other";
}
示例4: getClassName
public static String getClassName(int sqlType)
{
if (sqlType == Types.BOOLEAN)
return Boolean.class.getName();
if (sqlType == Types.BINARY)
return Byte[].class.getName();
if (sqlType == Types.DATE)
return Date.class.getName();
if (sqlType == Types.DOUBLE || sqlType == Types.FLOAT || sqlType == Types.DECIMAL)
return Double.class.getName();
if (sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.TINYINT)
return Long.class.getName();
if (sqlType == Types.NVARCHAR)
return String.class.getName();
if (sqlType == Types.TIMESTAMP)
return Timestamp.class.getName();
if (sqlType == Types.ARRAY)
return Object.class.getName();
return null;
}
示例5: convert
public Integer convert(String value) {
if ("ARRAY".equals(value)) { return Types.ARRAY; }
if ("BIGINT".equals(value)) { return Types.BIGINT; }
if ("BINARY".equals(value)) { return Types.BINARY; }
if ("BIT".equals(value)) { return Types.BIT; }
if ("BLOB".equals(value)) { return Types.BLOB; }
if ("BOOLEAN".equals(value)) { return Types.BOOLEAN; }
if ("CHAR".equals(value)) { return Types.CHAR; }
if ("CLOB".equals(value)) { return Types.CLOB; }
return Types.OTHER;
}
示例6: 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();
}
示例7: getActualDataSize
public int getActualDataSize(int colType, Object data)
{
int size = 0;
switch (colType)
{
case Types.ARRAY:
break;
case Types.BOOLEAN:
size = 1;
break;
case Types.BINARY:
if (data != null && byte[].class.equals(data.getClass()))
size = ((byte[]) data).length;
else if (data != null && ByteArray.class.equals(data))
size = ((ByteArray) data).length();
break;
case Types.DATE:
size = 4;
break;
case Types.DOUBLE:
size = 8;
break;
case Types.BIGINT:
size = 8;
break;
case Types.NVARCHAR:
if (data != null && String.class.equals(data.getClass()))
size = ((String) data).getBytes().length;
break;
case Types.TIMESTAMP:
size = 12;
break;
}
return size;
}
示例8: setValues
@Override
public void setValues(PreparedStatement ps) throws SQLException {
int parameterPosition = 1;
if (this.args != null) {
for (int i = 0; i < this.args.length; i++) {
Object arg = this.args[i];
if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) {
Collection<?> entries = (Collection<?>) arg;
for (Object entry : entries) {
if (entry instanceof Object[]) {
Object[] valueArray = ((Object[]) entry);
for (Object argValue : valueArray) {
doSetValue(ps, parameterPosition, this.argTypes[i], argValue);
parameterPosition++;
}
}
else {
doSetValue(ps, parameterPosition, this.argTypes[i], entry);
parameterPosition++;
}
}
}
else {
doSetValue(ps, parameterPosition, this.argTypes[i], arg);
parameterPosition++;
}
}
}
}
示例9: 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;
}
示例10: getSQLType
/**
* Get the SQLType for the given java.sql.Type type.
*
* @param type the java.sql.Type type specifier
* @return SQLType.the SQLType for this java.sql.Type, or null if it's not recognized
*/
public static SQLType getSQLType(int type) {
switch (type) {
case Types.BIT: return SQLType.BIT;
case Types.TINYINT: return SQLType.TINYINT;
case Types.SMALLINT: return SQLType.SMALLINT;
case Types.INTEGER: return SQLType.INTEGER;
case Types.BIGINT: return SQLType.BIGINT;
case Types.FLOAT: return SQLType.FLOAT;
case Types.REAL: return SQLType.REAL;
case Types.DOUBLE: return SQLType.DOUBLE;
case Types.NUMERIC: return SQLType.NUMERIC;
case Types.DECIMAL: return SQLType.DECIMAL;
case Types.CHAR: return SQLType.CHAR;
case Types.VARCHAR: return SQLType.VARCHAR;
case Types.LONGVARCHAR: return SQLType.LONGVARCHAR;
case Types.DATE: return SQLType.DATE;
case Types.TIME: return SQLType.TIME;
case Types.TIMESTAMP: return SQLType.TIMESTAMP;
case Types.BINARY: return SQLType.BINARY;
case Types.VARBINARY: return SQLType.VARBINARY;
case Types.LONGVARBINARY: return SQLType.LONGVARBINARY;
case Types.NULL: return SQLType.NULL;
case Types.OTHER: return SQLType.OTHER;
case Types.JAVA_OBJECT: return SQLType.JAVA_OBJECT;
case Types.DISTINCT: return SQLType.DISTINCT;
case Types.STRUCT: return SQLType.STRUCT;
case Types.ARRAY: return SQLType.ARRAY;
case Types.BLOB: return SQLType.BLOB;
case Types.CLOB: return SQLType.CLOB;
case Types.REF: return SQLType.REF;
case Types.DATALINK: return SQLType.DATALINK;
case Types.BOOLEAN: return SQLType.BOOLEAN;
case Types.LONGNVARCHAR: return SQLType.LONGVARCHAR;
case Types.NCHAR: return SQLType.CHAR;
case Types.NCLOB: return SQLType.CLOB;
case Types.NVARCHAR: return SQLType.VARCHAR;
case Types.SQLXML: return SQLType.SQLXML;
case Types.ROWID: return SQLType.ROWID;
default:
Logger.getLogger(JDBCUtils.class.getName()).log(Level.WARNING, "Unknown JDBC column type: " + type + ". Returns null.");
return null;
}
}
示例11: convertValue
private Object convertValue() throws SQLException {
switch (componentType.id) {
case Types.BOOLEAN:
case Types.BIT:
return componentAccessor.getBoolean();
case Types.TINYINT:
return componentAccessor.getByte();
case Types.SMALLINT:
return componentAccessor.getShort();
case Types.INTEGER:
return componentAccessor.getInt();
case Types.BIGINT:
return componentAccessor.getLong();
case Types.FLOAT:
return componentAccessor.getFloat();
case Types.DOUBLE:
return componentAccessor.getDouble();
case Types.ARRAY:
return componentAccessor.getArray();
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.NCHAR:
case Types.LONGNVARCHAR:
return componentAccessor.getString();
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return componentAccessor.getBytes();
case Types.DECIMAL:
return componentAccessor.getBigDecimal();
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.STRUCT:
case Types.JAVA_OBJECT:
return componentAccessor.getObject();
default:
throw new IllegalStateException("Unhandled ARRAY component type: " + componentType.rep
+ ", id: " + componentType.id);
}
}
示例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
}
}
示例13: 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
*/
public 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;
}
示例14: getParameterJavaValue
static public Object getParameterJavaValue(int param_type, String value) throws UnsupportedEncodingException, MalformedURLException, SQLException {
if (value != null) {
switch (param_type) {
case Types.ARRAY:
return value.split(",");
case Types.BIGINT:
return Long.valueOf(value);
case Types.BINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.BIT:
return Boolean.valueOf(value);
case Types.BLOB:
return value;//connection.createBlob();//
case Types.BOOLEAN:
return Boolean.valueOf(value);
case Types.CHAR:
return String.valueOf(value);
case Types.CLOB:
return value;//connection.createClob();//
case Types.DATALINK:
return new java.net.URL(value);
case Types.DATE:
return java.sql.Date.valueOf(value);
case Types.DECIMAL:
return java.math.BigDecimal.valueOf(Double.valueOf(value));
case Types.DISTINCT:
return value;//Object.class;
case Types.DOUBLE:
return Double.valueOf(value);
case Types.FLOAT:
return Double.valueOf(value);
case Types.INTEGER:
return Integer.valueOf(value, 10);
case Types.JAVA_OBJECT:
return value;//Object.class;
case Types.LONGVARBINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.LONGVARCHAR:
return String.valueOf(value);
case Types.NCLOB:
return value;//connection.createNClob();//
case Types.NULL:
return null;//Object.class;
case Types.NUMERIC:
return java.math.BigDecimal.valueOf(Double.parseDouble(value));
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
return String.valueOf(value);
case Types.OTHER:
return value;//Object.class;
case Types.REAL:
return Float.parseFloat(value);
case Types.REF:
return value;//java.sql.Ref.class;
case Types.ROWID:
return value;//java.sql.RowId.class;
case Types.SMALLINT:
return Short.valueOf(value);
case Types.STRUCT:
return value;//connection.createStruct(typeName, attributes);//
case Types.SQLXML:
return value;//connection.createSQLXML();//
case Types.TIME:
return java.sql.Time.valueOf(value);
case Types.TIMESTAMP:
return java.sql.Timestamp.valueOf(value);
case Types.TINYINT:
return Byte.valueOf(value);
case Types.VARBINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.VARCHAR:
return String.valueOf(value);
default:
return value;
}
}
return null;
}
示例15: 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;
}
}