Exemplo n.º 1
0
 private static Connection createConnection(String dataSourceId)
     throws SQLException, DataServiceFault {
   DataSourceService dataSourceService = DataServicesDSComponent.getDataSourceService();
   CarbonDataSource cds;
   try {
     cds = dataSourceService.getDataSource(dataSourceId);
   } catch (DataSourceException e) {
     throw new DataServiceFault(e, "Error in retrieving data source: " + e.getMessage());
   }
   if (cds == null) {
     throw new DataServiceFault("DataSource '" + dataSourceId + "' is not available.");
   }
   Object ds = cds.getDSObject();
   if (!(ds instanceof DataSource)) {
     throw new DataServiceFault("DataSource '" + dataSourceId + "' is not an RDBMS data source.");
   }
   return ((DataSource) ds).getConnection();
 }