Пример #1
0
 /**
  * Creates a JdbcSchema, taking credentials from a map.
  *
  * @param parentSchema Parent schema
  * @param name Name
  * @param operand Map of property/value pairs
  * @return A JdbcSchema
  */
 public static JdbcSchema create(
     SchemaPlus parentSchema, String name, Map<String, Object> operand) {
   DataSource dataSource;
   try {
     final String dataSourceName = (String) operand.get("dataSource");
     if (dataSourceName != null) {
       final Class<?> clazz = Class.forName((String) dataSourceName);
       dataSource = (DataSource) clazz.newInstance();
     } else {
       final String jdbcUrl = (String) operand.get("jdbcUrl");
       final String jdbcDriver = (String) operand.get("jdbcDriver");
       final String jdbcUser = (String) operand.get("jdbcUser");
       final String jdbcPassword = (String) operand.get("jdbcPassword");
       dataSource = dataSource(jdbcUrl, jdbcDriver, jdbcUser, jdbcPassword);
     }
   } catch (Exception e) {
     throw new RuntimeException("Error while reading dataSource", e);
   }
   String jdbcCatalog = (String) operand.get("jdbcCatalog");
   String jdbcSchema = (String) operand.get("jdbcSchema");
   return JdbcSchema.create(parentSchema, name, dataSource, jdbcCatalog, jdbcSchema);
 }
Пример #2
0
 public Schema create(SchemaPlus parentSchema, String name, Map<String, Object> operand) {
   return JdbcSchema.create(parentSchema, name, operand);
 }