use of org.datanucleus.store.rdbms.exceptions.UnsupportedDataTypeException in project datanucleus-rdbms by datanucleus.
the class RDBMSStoreManager method getSQLTypeInfoForJDBCType.
/**
* Accessor for the SQL type info for the specified JDBC type.
* @param jdbcType JDBC type
* @param sqlType The SQL type name (if known, otherwise uses the default for this JDBC type).
* @return SQL type info
* @throws UnsupportedDataTypeException If the JDBC type is not found
*/
public SQLTypeInfo getSQLTypeInfoForJDBCType(int jdbcType, String sqlType) throws UnsupportedDataTypeException {
RDBMSTypesInfo typesInfo = (RDBMSTypesInfo) schemaHandler.getSchemaData(null, RDBMSSchemaHandler.TYPE_TYPES, null);
JDBCTypeInfo jdbcTypeInfo = (JDBCTypeInfo) typesInfo.getChild("" + jdbcType);
if (jdbcTypeInfo.getNumberOfChildren() == 0) {
// No sql-type for this jdbc-type so unsupported
throw new UnsupportedDataTypeException(Localiser.msg("051005", dba.getNameForJDBCType(jdbcType)));
}
SQLTypeInfo sqlTypeInfo = (SQLTypeInfo) jdbcTypeInfo.getChild(sqlType != null ? sqlType : "DEFAULT");
if (sqlTypeInfo == null && sqlType != null) {
// Try uppercase form of sql-type
sqlTypeInfo = (SQLTypeInfo) jdbcTypeInfo.getChild(sqlType.toUpperCase());
if (sqlTypeInfo == null) {
// Try lowercase form of sql-type
sqlTypeInfo = (SQLTypeInfo) jdbcTypeInfo.getChild(sqlType.toLowerCase());
if (sqlTypeInfo == null) {
// fallback to DEFAULT
NucleusLogger.DATASTORE_SCHEMA.debug("Attempt to find JDBC driver 'typeInfo' for jdbc-type=" + dba.getNameForJDBCType(jdbcType) + " but sql-type=" + sqlType + " is not found. Using default sql-type for this jdbc-type.");
sqlTypeInfo = (SQLTypeInfo) jdbcTypeInfo.getChild("DEFAULT");
}
}
}
return sqlTypeInfo;
}
Aggregations