List of usage examples for java.sql Types BOOLEAN
int BOOLEAN
To view the source code for java.sql Types BOOLEAN.
Click Source Link
BOOLEAN
. From source file:org.seasar.dbflute.logic.replaceschema.loaddata.impl.DfAbsractDataWriter.java
/** * Get the bind type to find a value type. * @param tableName The name of table corresponding to column. (NotNull) * @param columnMeta The meta info of column. (NotNull) * @return The type of column. (NullAllowed: However Basically NotNull) *//*from ww w. j a v a2 s .c om*/ protected Class<?> getBindType(String tableName, DfColumnMeta columnMeta) { Map<String, Class<?>> cacheMap = _bindTypeCacheMap.get(tableName); if (cacheMap == null) { cacheMap = StringKeyMap.createAsFlexibleOrdered(); _bindTypeCacheMap.put(tableName, cacheMap); } final String columnName = columnMeta.getColumnName(); Class<?> bindType = cacheMap.get(columnName); if (bindType != null) { // cache hit return bindType; } // use mapped JDBC defined value if found (basically found) // because it has already been resolved about JDBC specification per DBMS final String jdbcType = _columnHandler.getColumnJdbcType(columnMeta); Integer jdbcDefValue = TypeMap.getJdbcDefValueByJdbcType(jdbcType); if (jdbcDefValue == null) { // basically no way jdbcDefValue = columnMeta.getJdbcDefValue(); // as plain } // ReplaceSchema uses an own original mapping way // (not uses Generate mapping) // it's simple mapping (for string processor) if (jdbcDefValue == Types.CHAR || jdbcDefValue == Types.VARCHAR || jdbcDefValue == Types.LONGVARCHAR || jdbcDefValue == Types.CLOB) { bindType = String.class; } else if (jdbcDefValue == Types.TINYINT || jdbcDefValue == Types.SMALLINT || jdbcDefValue == Types.INTEGER) { bindType = Integer.class; } else if (jdbcDefValue == Types.BIGINT) { bindType = Long.class; } else if (jdbcDefValue == Types.DECIMAL || jdbcDefValue == Types.NUMERIC) { bindType = BigDecimal.class; } else if (jdbcDefValue == Types.TIMESTAMP) { bindType = Timestamp.class; } else if (jdbcDefValue == Types.TIME) { bindType = Time.class; } else if (jdbcDefValue == Types.DATE) { // it depends on value type settings // that which is bound java.sql.Date or java.sql.Timestamp bindType = java.util.Date.class; } else if (jdbcDefValue == Types.BIT || jdbcDefValue == Types.BOOLEAN) { bindType = Boolean.class; } else if (jdbcDefValue == Types.BINARY || jdbcDefValue == Types.VARBINARY || jdbcDefValue == Types.LONGVARBINARY || jdbcDefValue == Types.BLOB) { bindType = byte[].class; } else if (jdbcDefValue == Types.OTHER && TypeMap.UUID.equalsIgnoreCase(jdbcType)) { // [UUID Headache]: The reason why UUID type has not been supported yet on JDBC. bindType = UUID.class; } else { bindType = Object.class; } cacheMap.put(columnName, bindType); return bindType; }
From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java
/** * Resolve a database-specific type to HCat data type. Largely follows Sqoop's * hive translation.//from ww w. j av a 2 s . c om * @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); } }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public int removeItemAssocsQBE(ItemAssocVO<Integer, Integer> itemAssoc) { // validate input parameters validateOneAttributeSet(itemAssoc);//from w w w . j av a 2 s. c o m if (logger.isDebugEnabled()) { logger.debug("removing 'itemAssoc' that match the following Example '" + itemAssoc + "'"); } StringBuilder sqlString = new StringBuilder("DELETE FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); List<Object> args = Lists.newArrayList(); List<Integer> argt = Lists.newArrayList(); // add constraints to the query if (itemAssoc.getId() != null) { sqlString.append(DEFAULT_ID_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getId()); argt.add(Types.INTEGER); } if (itemAssoc.getTenant() != null) { sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getTenant()); argt.add(Types.INTEGER); } if (itemAssoc.getItemFrom() != null) { ItemVO<Integer, Integer> itemFrom = itemAssoc.getItemFrom(); if (itemFrom.getItem() != null) { sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemFrom.getItem()); argt.add(Types.INTEGER); } if (itemFrom.getType() != null) { sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemFrom.getType()); argt.add(Types.INTEGER); } } if (itemAssoc.getAssocType() != null) { sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getAssocType()); argt.add(Types.INTEGER); } if (itemAssoc.getAssocValue() != null) { sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getAssocValue()); argt.add(Types.DOUBLE); } if (itemAssoc.getItemTo() != null) { ItemVO<Integer, Integer> itemTo = itemAssoc.getItemTo(); if (itemTo.getItem() != null) { sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemTo.getItem()); argt.add(Types.INTEGER); } if (itemTo.getType() != null) { sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemTo.getType()); argt.add(Types.INTEGER); } } if (itemAssoc.getSourceType() != null) { sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getSourceType()); argt.add(Types.INTEGER); } if (itemAssoc.getSourceInfo() != null) { sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME); sqlString.append(" LIKE ? AND "); args.add(itemAssoc.getSourceInfo()); argt.add(Types.VARCHAR); } if (itemAssoc.getViewType() != null) { sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.getViewType()); argt.add(Types.INTEGER); } if (itemAssoc.isActive() != null) { sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME); sqlString.append("=? AND "); args.add(itemAssoc.isActive()); argt.add(Types.BOOLEAN); } if (itemAssoc.getChangeDate() != null) { sqlString.append("changeDate"); sqlString.append("=? AND "); args.add(itemAssoc.getChangeDate()); argt.add(Types.TIMESTAMP); } // remove trailing " AND " sqlString.delete(sqlString.length() - 5, sqlString.length()); return getJdbcTemplate().update(sqlString.toString(), args.toArray(), Ints.toArray(argt)); }
From source file:org.jumpmind.symmetric.db.AbstractTriggerTemplate.java
protected String buildKeyVariablesDeclare(Column[] columns, String prefix) { String text = ""; for (int i = 0; i < columns.length; i++) { text += "declare @" + prefix + "pk" + i + " "; switch (columns[i].getMappedTypeCode()) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: text += "bigint\n"; break; case Types.NUMERIC: case Types.DECIMAL: text += "decimal\n"; break; case Types.FLOAT: case Types.REAL: case Types.DOUBLE: text += "float\n"; break; case Types.CHAR: case Types.VARCHAR: case ColumnTypes.NVARCHAR: case ColumnTypes.LONGNVARCHAR: case Types.LONGVARCHAR: text += "varchar(1000)\n"; break; case Types.DATE: text += "date\n"; break; case Types.TIME: text += "time\n"; break; case Types.TIMESTAMP: text += "datetime\n"; break; case Types.BOOLEAN: case Types.BIT: text += "bit\n"; break; case Types.CLOB: text += "varchar(max)\n"; break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case -10: // SQL-Server ntext binary type text += "varbinary(max)\n"; break; case Types.OTHER: text += "varbinary(max)\n"; break; default:/* w w w .j a va2s .c o m*/ if (columns[i].getJdbcTypeName() != null && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) { text += "interval"; break; } throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType()); } } return text; }
From source file:com.mirth.connect.donkey.test.util.TestUtils.java
private static String typeToString(int sqlType) { switch (sqlType) { case Types.ARRAY: return "ARRAY"; case Types.BIGINT: return "BIGINT"; case Types.BINARY: return "BINARY"; case Types.BIT: return "BIT"; case Types.BLOB: return "BLOB"; case Types.BOOLEAN: return "BOOLEAN"; case Types.CHAR: return "CHAR"; case Types.CLOB: return "CLOB"; case Types.DATALINK: return "DATALINK"; case Types.DATE: return "DATE"; case Types.DECIMAL: return "DECIMAL"; case Types.DISTINCT: return "DISTINCT"; case Types.DOUBLE: return "DOUBLE"; case Types.FLOAT: return "FLOAT"; case Types.INTEGER: return "INTEGER"; case Types.JAVA_OBJECT: return "JAVA_OBJECT"; case Types.LONGNVARCHAR: return "LONGNVARCHAR"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.LONGVARCHAR: return "LONGVARCHAR"; case Types.NCHAR: return "NCHAR"; case Types.NCLOB: return "NCLOB"; case Types.NULL: return "NULL"; case Types.NUMERIC: return "NUMERIC"; case Types.NVARCHAR: return "NVARCHAR"; case Types.OTHER: return "OTHER"; case Types.REAL: return "REAL"; case Types.REF: return "REF"; case Types.ROWID: return "ROWID"; case Types.SMALLINT: return "SMALLINT"; case Types.SQLXML: return "SQLXML"; case Types.STRUCT: return "STRUCT"; case Types.TIME: return "TIME"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.TINYINT: return "TINYINT"; case Types.VARBINARY: return "VARBINARY"; case Types.VARCHAR: return "VARCHAR"; default://from ww w.j a v a 2 s.c om return "UNKNOWN"; } }
From source file:org.apache.gobblin.source.jdbc.JdbcExtractor.java
private String parseColumnAsString(final ResultSet resultset, final ResultSetMetaData resultsetMetadata, int i) throws SQLException { if (isBlob(resultsetMetadata.getColumnType(i))) { return readBlobAsString(resultset.getBlob(i)); }// w w w .j a v a2s. co m if (isClob(resultsetMetadata.getColumnType(i))) { return readClobAsString(resultset.getClob(i)); } if ((resultsetMetadata.getColumnType(i) == Types.BIT || resultsetMetadata.getColumnType(i) == Types.BOOLEAN) && convertBitToBoolean()) { return Boolean.toString(resultset.getBoolean(i)); } return resultset.getString(i); }
From source file:org.wso2.carbon.dataservices.core.description.query.SQLQuery.java
private DataEntry getDataEntryFromRS(ResultSet rs) throws SQLException { DataEntry dataEntry = new DataEntry(); ResultSetMetaData metaData = rs.getMetaData(); int columnCount = metaData.getColumnCount(); int columnType; String value;/*from w ww . j a va 2 s .c o m*/ ParamValue paramValue; Time sqlTime; Date sqlDate; Timestamp sqlTimestamp; Blob sqlBlob; BigDecimal bigDecimal; InputStream binInStream; boolean useColumnNumbers = this.isUsingColumnNumbers(); for (int i = 1; i <= columnCount; i++) { /* retrieve values according to the column type */ columnType = metaData.getColumnType(i); switch (columnType) { /* handle string types */ case Types.VARCHAR: /* fall through */ case Types.LONGVARCHAR: /* fall through */ case Types.CHAR: /* fall through */ case Types.CLOB: /* fall through */ case Types.NCHAR: /* fall through */ case Types.NCLOB: /* fall through */ case Types.NVARCHAR: /* fall through */ case Types.LONGNVARCHAR: value = rs.getString(i); paramValue = new ParamValue(value); break; /* handle numbers */ case Types.INTEGER: /* fall through */ case Types.TINYINT: /* fall through */ case Types.SMALLINT: value = ConverterUtil.convertToString(rs.getInt(i)); paramValue = new ParamValue(rs.wasNull() ? null : value); break; case Types.DOUBLE: value = ConverterUtil.convertToString(rs.getDouble(i)); paramValue = new ParamValue(rs.wasNull() ? null : value); break; case Types.FLOAT: value = ConverterUtil.convertToString(rs.getFloat(i)); paramValue = new ParamValue(rs.wasNull() ? null : value); break; case Types.BOOLEAN: /* fall through */ case Types.BIT: value = ConverterUtil.convertToString(rs.getBoolean(i)); paramValue = new ParamValue(rs.wasNull() ? null : value); break; case Types.DECIMAL: bigDecimal = rs.getBigDecimal(i); if (bigDecimal != null) { value = ConverterUtil.convertToString(bigDecimal); } else { value = null; } paramValue = new ParamValue(value); break; /* handle data/time values */ case Types.TIME: /* handle time data type */ sqlTime = rs.getTime(i); if (sqlTime != null) { value = this.convertToTimeString(sqlTime); } else { value = null; } paramValue = new ParamValue(value); break; case Types.DATE: /* handle date data type */ sqlDate = rs.getDate(i); if (sqlDate != null) { value = ConverterUtil.convertToString(sqlDate); } else { value = null; } paramValue = new ParamValue(value); break; case Types.TIMESTAMP: sqlTimestamp = rs.getTimestamp(i, calendar); if (sqlTimestamp != null) { value = this.convertToTimestampString(sqlTimestamp); } else { value = null; } paramValue = new ParamValue(value); break; /* handle binary types */ case Types.BLOB: sqlBlob = rs.getBlob(i); if (sqlBlob != null) { value = this.getBase64StringFromInputStream(sqlBlob.getBinaryStream()); } else { value = null; } paramValue = new ParamValue(value); break; case Types.BINARY: /* fall through */ case Types.LONGVARBINARY: /* fall through */ case Types.VARBINARY: binInStream = rs.getBinaryStream(i); if (binInStream != null) { value = this.getBase64StringFromInputStream(binInStream); } else { value = null; } paramValue = new ParamValue(value); break; /* handling User Defined Types */ case Types.STRUCT: Struct udt = (Struct) rs.getObject(i); paramValue = new ParamValue(udt); break; case Types.ARRAY: paramValue = new ParamValue(ParamValue.PARAM_VALUE_ARRAY); Array dataArray = (Array) rs.getObject(i); if (dataArray == null) { break; } paramValue = this.processSQLArray(dataArray, paramValue); break; case Types.NUMERIC: bigDecimal = rs.getBigDecimal(i); if (bigDecimal != null) { value = ConverterUtil.convertToString(bigDecimal); } else { value = null; } paramValue = new ParamValue(value); break; case Types.BIGINT: value = ConverterUtil.convertToString(rs.getLong(i)); paramValue = new ParamValue(rs.wasNull() ? null : value); break; /* handle all other types as strings */ default: value = rs.getString(i); paramValue = new ParamValue(value); break; } dataEntry.addValue(useColumnNumbers ? Integer.toString(i) : metaData.getColumnLabel(i), paramValue); } return dataEntry; }
From source file:org.acmsl.queryj.metadata.engines.JdbcTypeManager.java
/** * {@inheritDoc}//from w ww. ja v a 2s . co m */ @NotNull @Override public List<Integer> getCompatibleTypesFor(final int type) { @NotNull final List<Integer> result = new ArrayList<>(); switch (type) { case Types.CHAR: case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.VARCHAR: result.add(Types.CHAR); result.add(Types.LONGNVARCHAR); result.add(Types.LONGVARCHAR); result.add(Types.NCHAR); result.add(Types.NVARCHAR); result.add(Types.VARCHAR); break; case Types.NUMERIC: case Types.BIGINT: case Types.BIT: case Types.BOOLEAN: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.INTEGER: case Types.REAL: case Types.SMALLINT: case Types.TINYINT: result.add(Types.NUMERIC); result.add(Types.BIGINT); result.add(Types.BIT); result.add(Types.BOOLEAN); result.add(Types.DECIMAL); result.add(Types.DOUBLE); result.add(Types.FLOAT); result.add(Types.INTEGER); result.add(Types.REAL); result.add(Types.SMALLINT); result.add(Types.TINYINT); break; default: break; } return result; }
From source file:org.wso2.carbon.dataservices.core.odata.RDBMSDataHandler.java
private ODataDataType getODataDataType(int columnType) { ODataDataType dataType;// ww w. jav a2 s . co m switch (columnType) { case Types.INTEGER: dataType = ODataDataType.INT32; break; case Types.TINYINT: /* fall through */ case Types.SMALLINT: dataType = ODataDataType.INT16; break; case Types.DOUBLE: dataType = ODataDataType.DOUBLE; break; case Types.VARCHAR: /* fall through */ case Types.CHAR: /* fall through */ case Types.LONGVARCHAR: /* fall through */ case Types.CLOB: /* fall through */ case Types.LONGNVARCHAR: /* fall through */ case Types.NCHAR: /* fall through */ case Types.NVARCHAR: /* fall through */ case Types.NCLOB: /* fall through */ case Types.SQLXML: dataType = ODataDataType.STRING; break; case Types.BOOLEAN: /* fall through */ case Types.BIT: dataType = ODataDataType.BOOLEAN; break; case Types.BLOB: /* fall through */ case Types.BINARY: /* fall through */ case Types.LONGVARBINARY: /* fall through */ case Types.VARBINARY: dataType = ODataDataType.BINARY; break; case Types.DATE: dataType = ODataDataType.DATE; break; case Types.DECIMAL: /* fall through */ case Types.NUMERIC: dataType = ODataDataType.DECIMAL; break; case Types.FLOAT: /* fall through */ case Types.REAL: dataType = ODataDataType.SINGLE; break; case Types.TIME: dataType = ODataDataType.TIMEOFDAY; break; case Types.BIGINT: dataType = ODataDataType.INT64; break; case Types.TIMESTAMP: dataType = ODataDataType.DATE_TIMEOFFSET; break; default: dataType = ODataDataType.STRING; break; } return dataType; }
From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java
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:// w w w . j av a 2 s . co m return "<UNKNOWN>"; } }