// Get this mapper's JDBC URL
String mapperJdbcUrl = conf.get(mapperJdbcUrlPropertyName, null);
LOG.debug(String.format("Mapper %d has a JDBC URL of: %s", mapperId,
mapperJdbcUrl == null ? "<null>" : mapperJdbcUrl));
DBConfiguration dbConf = getDBConf();
if (mapperJdbcUrl != null) {
// Just changing the URL_PROPERTY in the conf object does not work - as
// dbConf.getConf()
// seems to refer to a separate instance of the configuration properties.
// Therefore, we
// need to update the URL_PROPERTY in dbConf so that we connect to the
// appropriate instance
// in the Oracle RAC. To help avoid confusion, we'll also update the
// URL_PROPERTY in the
// conf object to match...
dbConf.getConf().set(DBConfiguration.URL_PROPERTY, mapperJdbcUrl);
conf.set(DBConfiguration.URL_PROPERTY, mapperJdbcUrl);
}
@SuppressWarnings("unchecked")
Class<T> inputClass = (Class<T>) (dbConf.getInputClass());
try {
// Use Oracle-specific db reader
// this.getConnection() will return the connection created when the
// DBInputFormat ancestor
// was created. This connection will be based on the URL_PROPERTY that was
// current at that
// time. We've just changed the URL_PROPERTY (if this is an Oracle RAC)
// and therefore need
// to use dbConf.getConnection() so that a new connection is created using
// the current
// value of the URL_PROPERTY...
return new OraOopDBRecordReader<T>(split, inputClass, conf, dbConf
.getConnection(), dbConf, dbConf.getInputConditions(), dbConf
.getInputFieldNames(), dbConf.getInputTableName());
} catch (SQLException ex) {
throw new IOException(ex);
} catch (ClassNotFoundException ex) {
throw new IOException(ex);
}