当前位置: 首页>>代码示例>>Java>>正文


Java Type.canConvertFrom方法代码示例

本文整理汇总了Java中org.hsqldb.types.Type.canConvertFrom方法的典型用法代码示例。如果您正苦于以下问题:Java Type.canConvertFrom方法的具体用法?Java Type.canConvertFrom怎么用?Java Type.canConvertFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hsqldb.types.Type的用法示例。


在下文中一共展示了Type.canConvertFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: supportsConvert

import org.hsqldb.types.Type; //导入方法依赖的package包/类
/**
 * (JDBC4 clarification:)
 * Retrieves whether this database supports the JDBC scalar function
 * <code>CONVERT</code> for conversions between the JDBC types <i>fromType</i>
 * and <i>toType</i>.  The JDBC types are the generic SQL data types defined
 * in <code>java.sql.Types</code>.
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * HSQLDB 2.0 supports conversion according to SQL standards. In addition,
 * it supports conversion between values of BOOLEAN and BIT types.
 * </div>
 * <!-- end release-specific documentation -->
 *
 *
 * @param fromType the type to convert from; one of the type codes from
 *        the class <code>java.sql.Types</code>
 * @param toType the type to convert to; one of the type codes from
 *        the class <code>java.sql.Types</code>
 * @return <code>true</code> if so; <code>false</code> otherwise
 * @exception SQLException if a database access error occurs
 * @see java.sql.Types
 */
public boolean supportsConvert(int fromType,
                               int toType) throws SQLException {

    Type from =
        Type.getDefaultTypeWithSize(Type.getHSQLDBTypeCode(fromType));
    Type to = Type.getDefaultTypeWithSize(Type.getHSQLDBTypeCode(toType));

    if (from == null || to == null) {
        return false;
    }

    if (fromType == java.sql.Types.NULL
            && toType == java.sql.Types.ARRAY) {
        return true;
    }

    return to.canConvertFrom(from);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:44,代码来源:JDBCDatabaseMetaData.java

示例2: supportsConvert

import org.hsqldb.types.Type; //导入方法依赖的package包/类
/**
     * (JDBC4 clarification:)
     * Retrieves whether this database supports the JDBC scalar function
     * <code>CONVERT</code> for conversions between the JDBC types <i>fromType</i>
     * and <i>toType</i>.  The JDBC types are the generic SQL data types defined
     * in <code>java.sql.Types</code>.
     *
     * <!-- start release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB 1.9.0 supports conversion according to SQL standards. In addition,
     * it supports conversion between values of BOOLEAN and BIT types.
     * </div>
     * <!-- end release-specific documentation -->
     *
     *
     * @param fromType the type to convert from; one of the type codes from
     *        the class <code>java.sql.Types</code>
     * @param toType the type to convert to; one of the type codes from
     *        the class <code>java.sql.Types</code>
     * @return <code>true</code> if so; <code>false</code> otherwise
     * @exception SQLException if a database access error occurs
     * @see java.sql.Types
     */
    public boolean supportsConvert(int fromType,
                                   int toType) throws SQLException {

//#ifdef JAVA6
        switch (fromType) {

            case java.sql.Types.NCHAR : {
                fromType = java.sql.Types.CHAR;

                break;
            }
            case java.sql.Types.NCLOB : {
                fromType = java.sql.Types.CLOB;

                break;
            }
            case java.sql.Types.NVARCHAR : {
                fromType = java.sql.Types.VARCHAR;

                break;
            }
        }

        switch (toType) {

            case java.sql.Types.NCHAR : {
                toType = java.sql.Types.CHAR;

                break;
            }
            case java.sql.Types.NCLOB : {
                toType = java.sql.Types.CLOB;

                break;
            }
            case java.sql.Types.NVARCHAR : {
                toType = java.sql.Types.VARCHAR;

                break;
            }
        }

//#endif JAVA6
        Type from = Type.getDefaultType(Type.getHSQLDBTypeCode(fromType));
        Type to   = Type.getDefaultType(Type.getHSQLDBTypeCode(toType));

        if (from == null || to == null) {
            return false;
        }

        return to.canConvertFrom(from);
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:78,代码来源:JDBCDatabaseMetaData.java


注:本文中的org.hsqldb.types.Type.canConvertFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。