Verify access to a JDBC endpoint by verifying that a specified table is accessible.
@param muleContext
@param muleJdbcDataSourceName
@param tableName
482811
public static String pingJdbcEndpoint(MuleContext muleContext, String muleJdbcDataSourceName, String tableName) {
		
		DataSource ds = JdbcUtil.lookupDataSource(muleContext, muleJdbcDataSourceName);

		Connection c = null;
		Statement  s = null;
		ResultSet rs = null;

		try {
			c  = ds.getConnection();
			s  = c.createStatement();
			rs = s.executeQuery("select 1 from " + tableName);
			
		} catch (SQLException e) {
			return ERROR_PREFIX + ": The table " + tableName + " was not found in the data source " + muleJdbcDataSourceName + ", reason: " + e.getMessage();

		} finally {
	    	try {if (rs != null) rs.close();} catch (SQLException e) {}
	    	try {if ( s != null)  s.close();} catch (SQLException e) {}
	    	try {if ( c != null)  c.close();} catch (SQLException e) {}
		}
		
		return OK_PREFIX + ": The table " + tableName + " was found in the data source " + muleJdbcDataSourceName;
	}
731751
public boolean isDatasource(String datasourceName) throws Exception {
        Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES);
        String haystack = DATA_SOURCE;
        return null != findNodeInList(addr, haystack, datasourceName);
    }
667316
public void runQueryPermanentTable(String destinationDataset, String destinationTable)
      throws InterruptedException {
    // [START bigquery_query_destination_table]
    // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
    // String destinationDataset = 'my_destination_dataset';
    // String destinationTable = 'my_destination_table';
    String query = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;";
    QueryJobConfiguration queryConfig =
        // Note that setUseLegacySql is set to false by default
        QueryJobConfiguration.newBuilder(query)
            // Save the results of the query to a permanent table.
            .setDestinationTable(TableId.of(destinationDataset, destinationTable))
            .build();

    // Print the results.
    for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) {
      for (FieldValue val : row) {
        System.out.printf("%s,", val.toString());
      }
      System.out.printf("\n");
    }
    // [END bigquery_query_destination_table]
  }
1351620
@Override
    public java.util.concurrent.Future<DescribeTableResult> describeTableAsync(String tableName) {

        return describeTableAsync(new DescribeTableRequest().withTableName(tableName));
    }
666733
protected String getTableName(PersistentEntity domainClass, String sessionFactoryBeanName) {
        Mapping m = getMapping(domainClass);
        String tableName = null;
        if (m != null && m.getTableName() != null) {
            tableName = m.getTableName();
        }
        if (tableName == null) {
            String shortName = domainClass.getJavaClass().getSimpleName();
            PersistentEntityNamingStrategy namingStrategy = this.namingStrategy;

            if(namingStrategy != null) {
                tableName = namingStrategy.resolveTableName(domainClass);
            }
            if(tableName == null) {
                tableName = getNamingStrategy(sessionFactoryBeanName).classToTableName(shortName);
            }
        }
        return tableName;
    }
1157460
static TableReference getTable(String projectId, String datasetId, String tableName) {
    TableReference table = new TableReference();
    table.setDatasetId(datasetId);
    table.setProjectId(projectId);
    table.setTableId(tableName);
    return table;
  }
91053
public final Connection getConnection(final String dataSourceName) throws SQLException {
        return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
    }
1051590
@GuardedBy("this")
    private TableSource getTableSource(String databaseName, String tableName)
    {
        checkHoldsLock();

        checkReadable();
        Action<TableAndMore> tableAction = tableActions.get(new SchemaTableName(databaseName, tableName));
        if (tableAction == null) {
            return TableSource.PRE_EXISTING_TABLE;
        }
        switch (tableAction.getType()) {
            case ADD:
                return TableSource.CREATED_IN_THIS_TRANSACTION;
            case ALTER:
                throw new IllegalStateException("Tables are never altered in the current implementation");
            case DROP:
                throw new TableNotFoundException(new SchemaTableName(databaseName, tableName));
            case INSERT_EXISTING:
                return TableSource.PRE_EXISTING_TABLE;
            default:
                throw new IllegalStateException("Unknown action type");
        }
    }
1021775
@Override
    public void verifyOrCreateReport(String reportId) {
        checkNotNull(reportId, "reportId");

        String tableName = getTableName(reportId);
        if (_dataStore.getTableExists(tableName)) {
            return;  // Nothing to do.
        }

        try {
            // TODO: when run in the EU this should be routed to the US data center.
            _dataStore.createTable(tableName,
                    new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(),
                    ImmutableMap.<String, String>of(),
                    new AuditBuilder().setComment("create table").build()
            );
        } catch (TableExistsException e) {
            // This is expected if we're continuing an existing report.
        }
    }
226503
public Table getTable(String datasetName, String tableName) {
    // [START ]
    Table table = bigquery.getTable(datasetName, tableName);
    // [END ]
    return table;
  }
295938
private static DataSource getNewDataSource(final String dataSourceName) {
		try {
			Context context = new InitialContext();
			return (DataSource) context.lookup(dataSourceName);
		} catch (NamingException ex) {
			throw new UroborosqlRuntimeException("DataSource[" + dataSourceName + "] can not be acquired.", ex);
		}
	}
391333
@Override
    public java.util.concurrent.Future<UpdateTableResult> updateTableAsync(String tableName, ProvisionedThroughput provisionedThroughput) {

        return updateTableAsync(new UpdateTableRequest().withTableName(tableName).withProvisionedThroughput(provisionedThroughput));
    }
982918
public static String getDataSourceIdentifier(WSJdbcWrapper jdbcWrapper) {
        DSConfig config = jdbcWrapper.dsConfig.get();
        return config.jndiName == null ? config.id : config.jndiName;
    }
1211963
public static final void chkBMTFromXML(List<ContainerTransaction> tranAttrList, EnterpriseBean enterpriseBean, J2EEName j2eeName)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "chkBMTFromXML");

        if (tranAttrList != null && enterpriseBean != null) {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "tranAttrList non-null");

            // Elements of highestStyleOnMethod[] are initialized to zero by Java rules.

            // i : TranAttrList loop
            // j : MethodElements loop

            for (int i = 0; i < tranAttrList.size(); ++i) {
                ContainerTransaction methodTransaction = tranAttrList.get(i);
                List<com.ibm.ws.javaee.dd.ejb.Method> methodElements = methodTransaction.getMethodElements();
                for (int j = 0; j < methodElements.size(); ++j) {
                    com.ibm.ws.javaee.dd.ejb.Method me = methodElements.get(j);
                    if (isTraceOn && tc.isDebugEnabled()) {
                        trace(me, me.getInterfaceTypeValue() == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED ?
                                        "Interface type unspecified" :
                                        "Interface type: " + me.getInterfaceTypeValue());
                    }
                    if (enterpriseBean.getName().equals(me.getEnterpriseBeanName())) {

                        Tr.warning(tc, "BMT_DEFINES_CMT_ATTRIBUTES_CNTR0067W", new Object[] { j2eeName });

                    } // enterpriseBean name matches parm in methodExtension
                } // methodElements loop (j)
            } // tranAttrList loop (i)

        } // tranAttrList != nullcd

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "chkBMTFromXML");

        return;
    }
979958
public static boolean createTableIfNotExists(final Connection conn, final String tableName, final String schema) {
        if (doesTableExist(conn, tableName)) {
            return false;
        }

        try {
            execute(conn, schema);

            return true;
        } catch (SQLException e) {
            return false;
        }
    }
199398
public DataSource getDataSource(String dataSourceName) throws
      ServiceLocatorException {
    DataSource dataSource = null;
    try {
      if (cache.containsKey(dataSourceName)) {
        dataSource = (DataSource) cache.get(dataSourceName);
      } else {
        dataSource = (DataSource) ic.lookup(dataSourceName);
        cache.put(dataSourceName, dataSource);
      }
    } catch (NamingException ne) {
      throw new ServiceLocatorException(ne);
    } catch (Exception e) {
      throw new ServiceLocatorException(e);
    }
    return dataSource;
  }
1197032
private static boolean getAccessSetFromDB(final String _sql,
                                              final Object _criteria)
        throws CacheReloadException
    {
        boolean ret = false;
        Connection con = null;
        try {
            AccessSet accessSet = null;
            con = Context.getConnection();
            PreparedStatement stmt = null;
            try {
                stmt = con.prepareStatement(_sql);
                stmt.setObject(1, _criteria);
                final ResultSet rs = stmt.executeQuery();

                if (rs.next()) {
                    final long id = rs.getLong(1);
                    final String uuid = rs.getString(2);
                    final String name = rs.getString(3);
                    AccessSet.LOG.debug("read AccessSet '{}' (id = {}, uuid ={})", name, id, uuid);
                    accessSet = new AccessSet(id, uuid, name);
                }
                ret = true;
                rs.close();
            } finally {
                if (stmt != null) {
                    stmt.close();
                }
            }
            con.commit();
            if (accessSet != null) {
                accessSet.readLinks2AccessTypes();
                accessSet.readLinks2DMTypes();
                accessSet.readLinks2Status();
                accessSet.readLinks2Person();
                // needed due to cluster serialization that does not update automatically
                AccessSet.cacheAccessSet(accessSet);
            }
        } catch (final SQLException e) {
            throw new CacheReloadException("could not read roles", e);
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read roles", e);
        } finally {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (final SQLException e) {
                throw new CacheReloadException("could not read child type ids", e);
            }
        }
        return ret;
    }