Logo Search packages:      
Sourcecode: mysql-connector-java version File versions

boolean com::mysql::jdbc::DatabaseMetaData::supportsConvert ( int  fromType,
int  toType 
) throws SQLException [inline]

Is CONVERT between the given SQL types supported?

Parameters:
fromType the type to convert from
toType the type to convert to
Returns:
true if so
Exceptions:
SQLException if an error occurs
See also:
Types

Definition at line 5790 of file DatabaseMetaData.java.

                            {
        switch (fromType) {
        /* The char/binary types can be converted
         * to pretty much anything.
         */
        case java.sql.Types.CHAR:
        case java.sql.Types.VARCHAR:
        case java.sql.Types.LONGVARCHAR:
        case java.sql.Types.BINARY:
        case java.sql.Types.VARBINARY:
        case java.sql.Types.LONGVARBINARY:

            switch (toType) {
            case java.sql.Types.DECIMAL:
            case java.sql.Types.NUMERIC:
            case java.sql.Types.REAL:
            case java.sql.Types.TINYINT:
            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.FLOAT:
            case java.sql.Types.DOUBLE:
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
            case java.sql.Types.OTHER:
            case java.sql.Types.DATE:
            case java.sql.Types.TIME:
            case java.sql.Types.TIMESTAMP:
                return true;

            default:
                return false;
            }

        /* We don't handle the BIT type
         * yet.
         */
        case java.sql.Types.BIT:
            return false;

        /* The numeric types. Basically they can convert
         * among themselves, and with char/binary types.
         */
        case java.sql.Types.DECIMAL:
        case java.sql.Types.NUMERIC:
        case java.sql.Types.REAL:
        case java.sql.Types.TINYINT:
        case java.sql.Types.SMALLINT:
        case java.sql.Types.INTEGER:
        case java.sql.Types.BIGINT:
        case java.sql.Types.FLOAT:
        case java.sql.Types.DOUBLE:

            switch (toType) {
            case java.sql.Types.DECIMAL:
            case java.sql.Types.NUMERIC:
            case java.sql.Types.REAL:
            case java.sql.Types.TINYINT:
            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.FLOAT:
            case java.sql.Types.DOUBLE:
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
                return true;

            default:
                return false;
            }

        /* MySQL doesn't support a NULL type. */
        case java.sql.Types.NULL:
            return false;

        /* With this driver, this will always be a serialized
         * object, so the char/binary types will work.
         */
        case java.sql.Types.OTHER:

            switch (toType) {
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
                return true;

            default:
                return false;
            }

        /* Dates can be converted to char/binary types. */
        case java.sql.Types.DATE:

            switch (toType) {
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
                return true;

            default:
                return false;
            }

        /* Time can be converted to char/binary types */
        case java.sql.Types.TIME:

            switch (toType) {
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
                return true;

            default:
                return false;
            }

        /* Timestamp can be converted to char/binary types
         * and date/time types (with loss of precision).
         */
        case java.sql.Types.TIMESTAMP:

            switch (toType) {
            case java.sql.Types.CHAR:
            case java.sql.Types.VARCHAR:
            case java.sql.Types.LONGVARCHAR:
            case java.sql.Types.BINARY:
            case java.sql.Types.VARBINARY:
            case java.sql.Types.LONGVARBINARY:
            case java.sql.Types.TIME:
            case java.sql.Types.DATE:
                return true;

            default:
                return false;
            }

        /* We shouldn't get here! */
        default:
            return false; // not sure
        }
    }


Generated by  Doxygen 1.6.0   Back to index