Get the SQL type for an object.
@param o Object to get SQL type of.
@return SQL type of the object, Types.OTHER if cannot classify.
332549
public int getSqlType(Object o) {
        if (null == o) {
            return Types.NULL;
        }
        return getSqlType(o.getClass());
    }
921556
public int getColumnType(final int column) throws SQLException {
    ColumnInformation ci = getColumnInformation(column);
    switch (ci.getColumnType()) {
      case BIT:
        if (ci.getLength() == 1) {
          return Types.BIT;
        }
        return Types.VARBINARY;
      case TINYINT:
        if (ci.getLength() == 1 && options.tinyInt1isBit) {
          return Types.BIT;
        }
        return Types.TINYINT;
      case YEAR:
        if (options.yearIsDateType) {
          return Types.DATE;
        }
        return Types.SMALLINT;
      case BLOB:
        if (ci.getLength() < 0 || ci.getLength() > 16777215) {
          return Types.LONGVARBINARY;
        }
        return Types.VARBINARY;
      case VARCHAR:
      case VARSTRING:
        if (ci.isBinary()) {
          return Types.VARBINARY;
        }
        if (ci.getLength() < 0) {
          return Types.LONGVARCHAR;
        }
        return Types.VARCHAR;
      case STRING:
        if (ci.isBinary()) {
          return Types.BINARY;
        }
        return Types.CHAR;
      default:
        return ci.getColumnType().getSqlType();
    }

  }
547153
static private StringBuilder determineType(String name, Object o) {
        String value = null;
        if (o instanceof String || o instanceof StringBuffer || o instanceof java.nio.CharBuffer || o instanceof Integer || o instanceof Long || o instanceof Byte
            || o instanceof Double || o instanceof Float || o instanceof Short || o instanceof BigInteger || o instanceof java.math.BigDecimal) {
            value = o.toString();
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Skipping class: " + o.getClass());
            }
            return null;
        }

        // type="class" name="o"
        StringBuilder buffer = new StringBuilder(48);
        buffer.append(name);
        buffer.append("type=\"");
        // charbuffer is abstract so we might get HeapCharBuffer here, force it
        // to the generic layer in the XML output
        if (o instanceof java.nio.CharBuffer) {
            buffer.append("java.nio.CharBuffer");
        } else {
            buffer.append(o.getClass().getName());
        }
        buffer.append("\" ");
        buffer.append(name);
        buffer.append("=\"");
        buffer.append(value);
        buffer.append("\"");
        return buffer;
    }
91012
public static int getColumnType (Connection conn, String table,
                                     String column)
        throws SQLException
    {
        ResultSet rs = getColumnMetaData(conn, table, column);
        try {
            return rs.getInt("DATA_TYPE");
        } finally {
            rs.close();
        }
    }
1348534
public String getColumnClassName(int column) throws SQLException {
    Field field = getField(column);
    String result = connection.getTypeInfo().getJavaClass(field.getOID());

    if (result != null) {
      return result;
    }

    int sqlType = getSQLType(column);
    switch (sqlType) {
      case Types.ARRAY:
        return ("java.sql.Array");
      default:
        String type = getPGType(column);
        if ("unknown".equals(type)) {
          return ("java.lang.String");
        }
        return ("java.lang.Object");
    }
  }
93788
def sql_get_oids(self, where=None):
        '''
        
        '''
        table = self.lconfig.get('table')
        db = self.lconfig.get('db_schema_name') or self.lconfig.get('db')
        _oid = self.lconfig.get('_oid')
        if is_array(_oid):
            _oid = _oid[0]  # get the db column, not the field alias
        sql = 'SELECT DISTINCT %s.%s FROM %s.%s' % (table, _oid, db, table)
        if where:
            where = [where] if isinstance(where, basestring) else list(where)
            sql += ' WHERE %s' % ' OR '.join(where)
        result = sorted([r[_oid] for r in self._load_sql(sql)])
        return result
52159
public static <T> T queryForObject(String sql, Class<T> clz, Object... args) {
		T result = null;
		List<T> list = queryForList(sql, clz, args);
		if (list.size() > 0) {
			result = list.get(0);
		}
		return result;
	}
221362
public static String objectId(Object o)
    {
        return (o == null) ? "0x0" : o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
    }
43456
@Override
    public String getSQL() {

        if (userTypeModifier == null) {
            throw Error.runtimeError(ErrorCode.U_S0500, "Type");
        }

        return userTypeModifier.getSQL();
    }
91014
public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
	// used reflection to make sure this work with Java 5 and 6
	try {
	    return (T) stat.getClass().getMethod("getObject", new Class[] { int.class, Class.class }).invoke(stat, new Object[] { parameterIndex, type });
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    if (t instanceof InvocationTargetException && ((InvocationTargetException) t).getTargetException() instanceof SQLException)
		throw (SQLException) ((InvocationTargetException) t).getTargetException();
	    throw new PageRuntimeException(Caster.toPageException(t));
	}
    }
541090
@Override
    public int getSqlType(String paramName) {
        if (!hasValue(paramName)) {
            return TYPE_UNKNOWN;
        }
        Object value = getValue(paramName);
        return StatementCreatorUtils.javaTypeToSqlParameterType(value.getClass());
    }
146558
protected SqlForClass getSqlForClass(ClassDescriptor cld)
    {
        SqlForClass result = (SqlForClass) sqlForClass.get(cld);
        if(result == null)
        {
            result = newInstanceSqlForClass();
            sqlForClass.put(cld, result);
        }
        return result;
    }
6044
def get_org_types(self):
        
        if not self.client.session_id:
            self.client.request_session()

        object_query = "SELECT Objects() FROM OrganizationType"
        result = self.client.execute_object_query(object_query=object_query)
        msql_result = result['body']["ExecuteMSQLResult"]
        return self.package_org_types(msql_result["ResultValue"]
                                      ["ObjectSearchResult"]
                                      ["Objects"]["MemberSuiteObject"]
                                      )
458140
Integer getSqlDataType() {

        // values from SQL200n SQL CLI spec, or DITypes (which in turn borrows
        // first from java.sql.Types and then SQL200n SQL CLI spec) if there
        // was no corresponding value in SQL CLI
        switch (type) {

            case Types.SQL_ARRAY :
                return ValuePool.getInt(Types.SQL_ARRAY);           // SQL_ARRAY

            case Types.SQL_BIGINT :
                return ValuePool.getInt(Types.SQL_BIGINT);          // SQL_BIGINT

            case Types.SQL_BINARY :
                return ValuePool.getInt(Types.SQL_BLOB);            // fredt- was SQL_BIT_VARYING

            case Types.SQL_BOOLEAN :
                return ValuePool.getInt(Types.SQL_BOOLEAN);         // SQL_BOOLEAN

            case Types.SQL_BLOB :
                return ValuePool.getInt(Types.SQL_BLOB);            // SQL_BLOB

            case Types.SQL_CHAR :
                return ValuePool.getInt(Types.SQL_CHAR);            // SQL_CHAR

            case Types.SQL_NCHAR :
                return ValuePool.getInt(Types.SQL_NCHAR);

            case Types.SQL_CLOB :
                return ValuePool.getInt(Types.SQL_CLOB);            // SQL_CLOB

            case Types.NCLOB :
                return ValuePool.getInt(Types.SQL_CLOB);            // N/A : SQL_CLOB

            case Types.SQL_DATALINK :
                return ValuePool.getInt(Types.SQL_DATALINK);        // SQL_DATALINK

            case Types.SQL_DATE :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_DATE);         // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.SQL_DECIMAL :
                return ValuePool.getInt(Types.SQL_DECIMAL);         // SQL_DECIMAL

            case Types.DISTINCT :
                return ValuePool.getInt(Types.SQL_UDT);             // SQL_UDT

            case Types.SQL_DOUBLE :
                return ValuePool.getInt(Types.SQL_DOUBLE);          // SQL_DOUBLE

            case Types.SQL_FLOAT :
                return ValuePool.getInt(Types.SQL_FLOAT);           // SQL_FLOAT

            case Types.SQL_INTEGER :
                return ValuePool.getInt(Types.SQL_INTEGER);         // SQL_INTEGER

            case Types.JAVA_OBJECT :
                return ValuePool.getInt(Types.JAVA_OBJECT);         // N/A - maybe SQL_UDT?

            case Types.SQL_ALL_TYPES :
                return ValuePool.getInt(Types.SQL_ALL_TYPES);       // SQL_ALL_TYPES

            case Types.SQL_NUMERIC :
                return ValuePool.getInt(Types.SQL_NUMERIC);         // SQL_NUMERIC

            case Types.OTHER :
                return ValuePool.getInt(Types.OTHER);               // N/A - maybe SQL_UDT?

            case Types.SQL_REAL :
                return ValuePool.getInt(Types.SQL_REAL);            // SQL_REAL

            case Types.ROWID :
                return ValuePool.getInt(Types.SQL_GUID);

            case Types.SQL_REF :
                return ValuePool.getInt(Types.SQL_REF);             // SQL_REF

            case Types.SQL_SMALLINT :
                return ValuePool.getInt(Types.SQL_SMALLINT);        // SQL_SMALLINTEGER

            case Types.STRUCT :
                return ValuePool.getInt(Types.SQL_UDT);             // SQL_UDT

            case Types.SQL_TIME :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_TIME);         // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.SQL_TIMESTAMP :

                // NO:  This is the _concise_ code, whereas what we want to
                //      return here is the Data Type Code column value from
                //      Table 38 in the SQL CLI 200n FCD.  This method is used
                //      by DatabaseInformationMain to list the sql type
                //      column in the SYSTEM_TYPEINFO table, which is specified
                //      by JDBC as the sql data type code, not the concise code.
                //      That is why there is a sql datetime sub column
                //      specified as well.
                // return ValuePool.getInt(Types.SQL_TIMESTAMP);    // fredt - was SQL_DATETIME
                return ValuePool.getInt(Types.SQL_DATETIME);

            case Types.TINYINT :
                return ValuePool.getInt(Types.TINYINT);             // N/A

            case Types.SQL_VARBINARY :
                return ValuePool.getInt(Types.SQL_BLOB);            // SQL_BIT_VARYING

            case Types.SQL_VARCHAR :
                return ValuePool.getInt(Types.SQL_VARCHAR);         // SQL_VARCHAR

            case Types.VARCHAR_IGNORECASE :
                return ValuePool.getInt(Types.SQL_VARCHAR);         // SQL_VARCHAR

            case Types.SQL_NVARCHAR :
                return ValuePool.getInt(Types.SQL_NVARCHAR);

            case Types.SQL_XML :
                return ValuePool.getInt(Types.SQL_XML);             // SQLXML

            default :
                return null;
        }
    }
450285
public static Type newInstance(int sqlType) {
		switch (sqlType) {
		case (java.sql.Types.INTEGER):
			return INTEGER;
		case (java.sql.Types.BIGINT):
			return BIGINT;
		case (java.sql.Types.DOUBLE):
			return DOUBLE;
		case (java.sql.Types.VARCHAR):
			return VARCHAR;
		}
		throw new UnsupportedOperationException("Unspported SQL type: "
				+ sqlType);
	}
683897
public static Object getObjectFromColumn(ResultSet rs, Integer jdbcType, int columnId)
            throws SQLException
    {
        return getObjectFromColumn(rs, null, jdbcType, null, columnId);
    }
842490
public DatabaseType getDatabaseType() {
        if (lexer instanceof H2Lexer) {
            return DatabaseType.H2;
        }
        if (lexer instanceof MySQLLexer) {
            return DatabaseType.MySQL;
        }
        if (lexer instanceof OracleLexer) {
            return DatabaseType.Oracle;
        }
        if (lexer instanceof SQLServerLexer) {
            return DatabaseType.SQLServer;
        }
        if (lexer instanceof PostgreSQLLexer) {
            return DatabaseType.PostgreSQL;
        }
        throw new UnsupportedOperationException(String.format("Cannot support lexer class: %s", lexer.getClass().getCanonicalName()));
    }