本文整理汇总了Java中org.hsqldb.types.Type.getDefaultType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getDefaultType方法的具体用法?Java Type.getDefaultType怎么用?Java Type.getDefaultType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.types.Type
的用法示例。
在下文中一共展示了Type.getDefaultType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createArrayOf
import org.hsqldb.types.Type; //导入方法依赖的package包/类
/**
* Factory method for creating Array objects.
* <p>
* <b>Note: </b>When <code>createArrayOf</code> is used to create an array object
* that maps to a primitive data type, then it is implementation-defined
* whether the <code>Array</code> object is an array of that primitive
* data type or an array of <code>Object</code>.
* <p>
* <b>Note: </b>The JDBC driver is responsible for mapping the elements
* <code>Object</code> array to the default JDBC SQL type defined in
* java.sql.Types for the given class of <code>Object</code>. The default
* mapping is specified in Appendix B of the JDBC specification. If the
* resulting JDBC type is not the appropriate type for the given typeName then
* it is implementation defined whether an <code>SQLException</code> is
* thrown or the driver supports the resulting conversion.
*
* @param typeName the SQL name of the type the elements of the array map to. The typeName is a
* database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database. This
* is the value returned by <code>Array.getBaseTypeName</code>
* @param elements the elements that populate the returned object
* @return an Array object whose elements map to the specified SQL type
* @throws SQLException if a database error occurs, the JDBC type is not
* appropriate for the typeName and the conversion is not supported, the typeName is null or this method is called on a closed connection
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this data type
* @since 1.6
*/
//#ifdef JAVA6
public Array createArrayOf(String typeName,
Object[] elements) throws SQLException {
checkClosed();
if (typeName == null) {
throw JDBCUtil.nullArgument();
}
typeName = typeName.toUpperCase();
int typeCode = Type.getTypeNr(typeName);
if (typeCode < 0) {
throw JDBCUtil.invalidArgument(typeName);
}
Type type = Type.getDefaultType(typeCode);
if (type.isArrayType() || type.isLobType() || type.isRowType()) {
throw JDBCUtil.invalidArgument(typeName);
}
Object[] newData = new Object[elements.length];
try {
for (int i = 0; i < elements.length; i++) {
Object o = type.convertJavaToSQL(sessionProxy, elements[i]);
newData[i] = type.convertToTypeLimits(sessionProxy, o);
}
} catch (HsqlException e) {
throw JDBCUtil.sqlException(e);
}
return new JDBCArray(newData, type, this);
}
示例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);
}
示例3: getMethod
import org.hsqldb.types.Type; //导入方法依赖的package包/类
static Method getMethod(String name, Type[] types, Type returnType,
boolean[] nullability, boolean[] hasConnection) {
int i = name.indexOf(':');
if (i != -1) {
if (!name.substring(0, i).equals(SqlInvariants.CLASSPATH_NAME)) {
throw Error.error(ErrorCode.X_46102, name);
}
name = name.substring(i + 1);
}
Method method = null;
Method[] methods = getMethods(name);
for (i = 0; i < methods.length; i++) {
int offset = 0;
Class[] params = methods[i].getParameterTypes();
if (params.length > 0
&& params[0].equals(java.sql.Connection.class)) {
offset = 1;
hasConnection[0] = true;
}
if (params.length - offset != types.length) {
continue;
}
Type methodReturnType = Type.getDefaultType(
Types.getParameterSQLTypeNumber(methods[i].getReturnType()));
if (methodReturnType == null) {
continue;
}
if (methodReturnType.typeCode != returnType.typeCode) {
continue;
}
method = methods[i];
for (int j = 0; j < types.length; j++) {
Class param = params[j + offset];
Type methodParamType = Type.getDefaultType(
Types.getParameterSQLTypeNumber(param));
if (methodParamType == null) {
break;
}
nullability[j] = !param.isPrimitive();
if (types[j].typeCode != methodParamType.typeCode) {
method = null;
break;
}
}
if (method != null) {
break;
}
}
return method;
}
示例4: readDataTypeSimple
import org.hsqldb.types.Type; //导入方法依赖的package包/类
Type readDataTypeSimple(RowInputBinary in) throws IOException {
int typeCode = in.readType();
boolean isArray = typeCode == Types.SQL_ARRAY;
if (isArray) {
typeCode = in.readType();
return Type.getDefaultArrayType(typeCode);
}
return Type.getDefaultType(typeCode);
}