本文整理汇总了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);
}
示例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);
}