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:com.splicemachine.derby.utils.SpliceAdmin.java
/** * Prints all the information related to the execution plans of the stored prepared statements (metadata queries). *///w ww.jav a 2s .c om public static void SYSCS_GET_STORED_STATEMENT_PLAN_INFO(ResultSet[] rs) throws SQLException { try { // Wow... who knew it was so much work to create a ResultSet? Ouch! The following code is annoying. LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); DataDictionary dd = lcc.getDataDictionary(); List list = dd.getAllSPSDescriptors(); ArrayList<ExecRow> rows = new ArrayList<>(list.size()); // Describe the format of the input rows (ExecRow). // // Columns of "virtual" row: // STMTNAME VARCHAR // TYPE CHAR // VALID BOOLEAN // LASTCOMPILED TIMESTAMP // INITIALLY_COMPILABLE BOOLEAN // CONSTANTSTATE BLOB --> VARCHAR showing existence of plan DataValueDescriptor[] dvds = new DataValueDescriptor[] { new SQLVarchar(), new SQLChar(), new SQLBoolean(), new SQLTimestamp(), new SQLBoolean(), new SQLVarchar() }; int numCols = dvds.length; ExecRow dataTemplate = new ValueRow(numCols); dataTemplate.setRowArray(dvds); // Transform the descriptors into the rows. for (Object aList : list) { SPSDescriptor spsd = (SPSDescriptor) aList; ExecPreparedStatement ps = spsd.getPreparedStatement(false); dvds[0].setValue(spsd.getName()); dvds[1].setValue(spsd.getTypeAsString()); dvds[2].setValue(spsd.isValid()); dvds[3].setValue(spsd.getCompileTime()); dvds[4].setValue(spsd.initiallyCompilable()); dvds[5].setValue(spsd.getPreparedStatement(false) == null ? null : "[object]"); rows.add(dataTemplate.getClone()); } // Describe the format of the output rows (ResultSet). ResultColumnDescriptor[] columnInfo = new ResultColumnDescriptor[numCols]; columnInfo[0] = new GenericColumnDescriptor("STMTNAME", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 60)); columnInfo[1] = new GenericColumnDescriptor("TYPE", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.CHAR, 4)); columnInfo[2] = new GenericColumnDescriptor("VALID", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.BOOLEAN)); columnInfo[3] = new GenericColumnDescriptor("LASTCOMPILED", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.TIMESTAMP)); columnInfo[4] = new GenericColumnDescriptor("INITIALLY_COMPILABLE", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.BOOLEAN)); columnInfo[5] = new GenericColumnDescriptor("CONSTANTSTATE", DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, 13)); EmbedConnection defaultConn = (EmbedConnection) getDefaultConn(); Activation lastActivation = defaultConn.getLanguageConnection().getLastActivation(); IteratorNoPutResultSet resultsToWrap = new IteratorNoPutResultSet(rows, columnInfo, lastActivation); resultsToWrap.openCore(); EmbedResultSet ers = new EmbedResultSet40(defaultConn, resultsToWrap, false, null, true); rs[0] = ers; } catch (StandardException se) { throw PublicAPI.wrapStandardException(se); } }
From source file:org.siphon.jssql.SqlExecutor.java
private String translateTypeName(int columnType, String columnTypeName) { switch (columnType) { case Types.VARCHAR: case Types.CHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: return "STRING"; case Types.INTEGER: case Types.SMALLINT: return "INT"; case Types.BIGINT: return "LONG"; case Types.FLOAT: return "FLOAT"; case Types.REAL: case Types.DOUBLE: return "DOUBLE"; case Types.NUMERIC: case Types.DECIMAL: return "DECIMAL"; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.TIME_WITH_TIMEZONE: return "DATE"; case Types.ROWID: return "ROWID"; case Types.BLOB: return "BINARY"; // return "BLOB"; case Types.CLOB: return "STRING"; // return "CLOB"; case Types.VARBINARY: case Types.LONGVARBINARY: return "BINARY"; case Types.BOOLEAN: return "BOOLEAN"; case Types.ARRAY: return "ARRAY"; case Types.OTHER: return columnTypeName.toUpperCase(); default:/*from w w w . j a va2 s .c o m*/ return "UNKNOWN"; } }
From source file:com.servoy.j2db.util.Utils.java
/** * The same as parseJSExpression but try to convert the object to the given type parameter * @param type from java.sql.Types , java.sql.Types.OTHER to get the behavior of parseJSExpression(Object o) *//*from w w w . j a v a 2 s.c om*/ public static Object parseJSExpression(Object o, int type) { if (o instanceof String) { int tp = Column.mapToDefaultType(type); String s = ((String) o).trim(); if ("".equals(s)) return null; if (tp == Types.OTHER || type == Types.BOOLEAN || type == Types.BIT) { if ("true".equals(s)) return Boolean.TRUE; if ("false".equals(s)) return Boolean.FALSE; if (type == Types.BOOLEAN || type == Types.BIT) return null; } if (tp == Types.OTHER || tp == IColumnTypes.NUMBER) { try { return Double.valueOf(s); } catch (NumberFormatException e) { if (tp != Types.OTHER) return null; } } if (tp == IColumnTypes.INTEGER) { try { return Integer.valueOf(s); } catch (NumberFormatException e) { if ("true".equals(s)) return Boolean.TRUE; if ("false".equals(s)) return Boolean.FALSE; return null; } } if (tp == Types.OTHER || tp == IColumnTypes.TEXT) { if ((s.charAt(0) == '\'' && s.charAt(s.length() - 1) == '\'') || (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"')) { return s.substring(1, s.length() - 1); } } return null; } // non-string, keep original return o; }
From source file:org.nuclos.server.dblayer.impl.standard.StandardSqlDBAccess.java
protected static DbGenericType getDbGenericType(int sqlType, String typeName) { switch (sqlType) { case Types.VARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.CHAR: return DbGenericType.VARCHAR; case Types.NUMERIC: case Types.DECIMAL: return DbGenericType.NUMERIC; case Types.BIT: case Types.BOOLEAN: return DbGenericType.BOOLEAN; case Types.DATE: return DbGenericType.DATE; case Types.BLOB: case Types.VARBINARY: case Types.BINARY: case Types.LONGVARBINARY: return DbGenericType.BLOB; case Types.CLOB: case Types.LONGVARCHAR: return DbGenericType.CLOB; case Types.TIMESTAMP: return DbGenericType.DATETIME; default:// w w w. j ava2s . c o m return null; } }
From source file:org.pentaho.di.jdbc.Support.java
/** * Retrieve the fully qualified java class name for the * supplied JDBC Types constant./*w ww . ja v a 2s .co m*/ * * @param jdbcType The JDBC Types constant. * @return The fully qualified java class name as a <code>String</code>. */ static String getClassName(int jdbcType) { switch (jdbcType) { case java.sql.Types.BOOLEAN: case java.sql.Types.BIT: return "java.lang.Boolean"; case java.sql.Types.TINYINT: case java.sql.Types.SMALLINT: case java.sql.Types.INTEGER: return "java.lang.Integer"; case java.sql.Types.BIGINT: return "java.lang.Long"; case java.sql.Types.NUMERIC: case java.sql.Types.DECIMAL: return "java.math.BigDecimal"; case java.sql.Types.REAL: return "java.lang.Float"; case java.sql.Types.FLOAT: case java.sql.Types.DOUBLE: return "java.lang.Double"; case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: return "java.lang.String"; case java.sql.Types.BINARY: case java.sql.Types.VARBINARY: return "[B"; case java.sql.Types.LONGVARBINARY: case java.sql.Types.BLOB: return "java.sql.Blob"; case java.sql.Types.LONGVARCHAR: case java.sql.Types.CLOB: return "java.sql.Clob"; case java.sql.Types.DATE: return "java.sql.Date"; case java.sql.Types.TIME: return "java.sql.Time"; case java.sql.Types.TIMESTAMP: return "java.sql.Timestamp"; default: break; } return "java.lang.Object"; }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public List<AssociatedItemVO<Integer, Integer>> getItemsFrom(Integer itemFromTypeId, Integer assocTypeId, ItemVO<Integer, Integer> itemTo, IAConstraintVO<Integer, Integer> constraints) { // validate input parameters validateItemTo(itemTo);// www . ja va 2 s.c o m validateConstraints(constraints); if (logger.isDebugEnabled()) { logger.debug("fetching 'itemsFrom' with itemFromTypeId='" + itemFromTypeId + "', assocTypeId='" + assocTypeId + "', itemTo=" + itemTo + " and constraints=" + constraints); } // generate sql string StringBuilder sqlString = new StringBuilder("SELECT "); sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ID_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append(" FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME); sqlString.append("=? AND "); sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME); sqlString.append("=?"); List<Object> args = Lists.newArrayList((Object) itemTo.getItem(), itemTo.getType()); List<Integer> argt = Lists.newArrayList(Types.INTEGER, Types.INTEGER); if (itemFromTypeId != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(itemFromTypeId); argt.add(Types.INTEGER); } if (assocTypeId != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(assocTypeId); argt.add(Types.INTEGER); } if (constraints.getSourceType() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getSourceType()); argt.add(Types.INTEGER); if (constraints.getSourceInfo() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME); sqlString.append(" LIKE ?"); args.add(constraints.getSourceInfo()); argt.add(Types.VARCHAR); } } if (constraints.getViewType() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getViewType()); argt.add(Types.INTEGER); } if (constraints.isActive() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.isActive()); argt.add(Types.BOOLEAN); } if (constraints.getTenant() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getTenant()); argt.add(Types.INTEGER); } if (constraints.getSortAsc() != null) { sqlString.append(" ORDER BY "); sqlString.append(constraints.getSortField()); sqlString.append(" "); if (constraints.getSortAsc()) sqlString.append(DaoUtils.ORDER_ASC); else sqlString.append(DaoUtils.ORDER_DESC); } // Note: for a non-mysql implementation this is need to be changed if (constraints.getNumberOfResults() != null && constraints.getNumberOfResults() > 0) { sqlString.append(" LIMIT ?"); args.add(constraints.getNumberOfResults()); argt.add(Types.INTEGER); } return getJdbcTemplate().query(sqlString.toString(), args.toArray(), Ints.toArray(argt), associatedItemFromVORowMapper); }
From source file:org.jumpmind.symmetric.db.ase.AseTriggerTemplate.java
@Override 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: // ASE does not support bigint text += "NUMERIC(18,0)\n"; break; case Types.NUMERIC: case Types.DECIMAL: // Use same default scale and precision used by Sybase ASA // for a decimal with unspecified scale and precision. text += "decimal(30,6)\n"; break; case Types.FLOAT: case Types.REAL: case Types.DOUBLE: text += "float\n"; break; case Types.CHAR: case Types.VARCHAR: 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(32767)\n"; break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case -10: // SQL-Server ntext binary type text += "varbinary(32767)\n"; break; case Types.OTHER: text += "varbinary(32767)\n"; break; default:/*from ww w .j a v a 2 s.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:io.bibleget.BibleGetDB.java
private void listColNamesTypes(DatabaseMetaData dbMeta, ResultSet rs) { //System.out.println("After Table Creation: Table "+rs.getString("TABLE_NAME")+" exists !!"); ResultSet cols;//from w w w. ja v a 2s . com try { cols = dbMeta.getColumns(null, null, rs.getString("TABLE_NAME"), null); while (cols.next()) { //System.out.println(cols.getString("COLUMN_NAME")); colNames.add(cols.getString("COLUMN_NAME")); int dType = cols.getInt("DATA_TYPE"); switch (dType) { case Types.VARCHAR: colDataTypes.add(String.class); break; case Types.INTEGER: colDataTypes.add(Integer.class); break; case Types.FLOAT: colDataTypes.add(Float.class); break; case Types.DOUBLE: case Types.REAL: colDataTypes.add(Double.class); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: colDataTypes.add(java.sql.Date.class); break; case Types.BOOLEAN: colDataTypes.add(Boolean.class); break; default: colDataTypes.add(String.class); break; } } } catch (SQLException ex) { Logger.getLogger(BibleGetDB.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.easyrec.store.dao.web.impl.LoaderDAOMysqlImpl.java
@Override public Operator addOperator(String id, String password, String firstName, String lastName, String email, String phone, String company, String address, String apiKey, String ip) { Object[] args = { id, password, firstName, lastName, email, phone, company, address, apiKey, ip, new Date(), true, 1 };/*from w w w. j av a2 s . c o m*/ int[] argTypes = { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.BOOLEAN, Types.INTEGER }; try { getJdbcTemplate().update(SQL_ADD_OPERATOR, args, argTypes); return new Operator(id, password, firstName, lastName, email, phone, company, address, apiKey, ip, true, // active new Date().toString(), // creation date 1, // acceslevel 0, // login count null // last login date ); } catch (Exception e) { logger.debug(e); e.printStackTrace(); return null; } }
From source file:org.easyrec.store.dao.core.impl.ItemAssocDAOMysqlImpl.java
@Override public List<AssociatedItemVO<Integer, Integer>> getItemsTo(ItemVO<Integer, Integer> itemFrom, Integer assocTypeId, Integer itemToTypeId, IAConstraintVO<Integer, Integer> constraints) { // validate input parameters validateItemFrom(itemFrom);/* w w w . j a va 2s . co m*/ validateConstraints(constraints); if (logger.isDebugEnabled()) { logger.debug("fetching 'itemsTo' with itemToTypeId='" + itemToTypeId + "', assocTypeId='" + assocTypeId + "', itemFrom=" + itemFrom + " and constraints=" + constraints); } // generate sql string StringBuilder sqlString = new StringBuilder("SELECT "); sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ID_COLUMN_NAME); sqlString.append(", "); sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append(" FROM "); sqlString.append(DEFAULT_TABLE_NAME); sqlString.append(" WHERE "); sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME); sqlString.append("=? AND "); sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME); sqlString.append("=?"); List<Object> args = Lists.newArrayList((Object) itemFrom.getItem(), itemFrom.getType()); List<Integer> argt = Lists.newArrayList(Types.INTEGER, Types.INTEGER); if (itemToTypeId != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(itemToTypeId); argt.add(Types.INTEGER); } if (assocTypeId != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(assocTypeId); argt.add(Types.INTEGER); } if (constraints.getSourceType() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getSourceType()); argt.add(Types.INTEGER); if (constraints.getSourceInfo() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME); sqlString.append(" LIKE ?"); args.add(constraints.getSourceInfo()); argt.add(Types.VARCHAR); } } if (constraints.getViewType() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getViewType()); argt.add(Types.INTEGER); } if (constraints.getTenant() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_TENANT_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.getTenant()); argt.add(Types.INTEGER); } if (constraints.isActive() != null) { sqlString.append(" AND "); sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME); sqlString.append("=?"); args.add(constraints.isActive()); argt.add(Types.BOOLEAN); } if (constraints.getSortAsc() != null) { sqlString.append(" ORDER BY "); sqlString.append(constraints.getSortField()); sqlString.append(" "); if (constraints.getSortAsc()) sqlString.append(DaoUtils.ORDER_ASC); else sqlString.append(DaoUtils.ORDER_DESC); } // Note: for a non-mysql implementation this is need to be changed if (constraints.getNumberOfResults() != null && constraints.getNumberOfResults() > 0) { sqlString.append(" LIMIT ?"); args.add(constraints.getNumberOfResults()); argt.add(Types.INTEGER); } return getJdbcTemplate().query(sqlString.toString(), args.toArray(), Ints.toArray(argt), associatedItemToVORowMapper); }