use of org.datanucleus.store.rdbms.schema.RDBMSTypesInfo 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, "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;
}
use of org.datanucleus.store.rdbms.schema.RDBMSTypesInfo in project datanucleus-rdbms by datanucleus.
the class BaseDatastoreAdapter method getSQLTypeInfoForJdbcType.
/**
* Accessor for the SQLType info for the specified JDBC type and the SQL type name.
* @param handler Schema handler
* @param mconn Connection
* @param jdbcTypeNumber JDBC type
* @return The SQL type info
*/
protected Collection<SQLTypeInfo> getSQLTypeInfoForJdbcType(StoreSchemaHandler handler, ManagedConnection mconn, short jdbcTypeNumber) {
RDBMSTypesInfo types = (RDBMSTypesInfo) handler.getSchemaData(mconn.getConnection(), "types", null);
String key = "" + jdbcTypeNumber;
org.datanucleus.store.rdbms.schema.JDBCTypeInfo jdbcType = (org.datanucleus.store.rdbms.schema.JDBCTypeInfo) types.getChild(key);
if (jdbcType == null) {
return null;
}
return jdbcType.getChildren().values();
}
Aggregations