-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
7.4
-
None
I have an execution factory that derives from TeiidExecutionFactory. Its job is to connect to the same Teiid instance, and execute a rewritten query. We use this to support dynamic view definitions. Below is the createResultSetExecution method:
@Override
public ResultSetExecution createResultSetExecution(final QueryExpression command,
final ExecutionContext executionContext,
final RuntimeMetadata metadata,
final Connection conn) throws TranslatorException
{
// TODO: This is not correct; this should be only called once for
// connection creation
obtainedConnection(conn);
return new ResultSetExecution()
{
private final List<Tuple> gatherResults = new ArrayList<Tuple>();
int i = 0;
@Override
public void execute() throws TranslatorException
{
try
{
ViewExecutionFactory.this.logger.info("execute() start");
ViewExecutionFactory.this.logger.info("before prepareStatement");
final PreparedStatement prepareStatement =
conn.prepareStatement("SELECT alert_id, alert_msg, lpar_id FROM demoalertdata.chorus.public.demo_alert");
ViewExecutionFactory.this.logger.info("beofre executeQuery");
final ResultSet resultSet = prepareStatement.executeQuery();
while (resultSet.next())
ViewExecutionFactory.this.logger.info("before reuslt set close");
resultSet.close();
ViewExecutionFactory.this.logger.info("before prepare statement close");
prepareStatement.close();
} catch (final Exception e)
finally
{ ViewExecutionFactory.this.logger.info("execute() end"); }}
@Override
public void close()
@Override
public void cancel() throws TranslatorException
{ // }
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException
{
if (this.i < this.gatherResults.size())
else
{ return null; } }
};
}
Under 7.4, when we issue a query against this translator, the thread hangs during the executeQuery() method. It works under 7.3.
Not sure if it's relevant but we connect to the local Teiid instance in the getConnection() method:
@Override
synchronized final public Connection getConnection(final DataSource ds) throws TranslatorException
{
if (this.metadataInitialized)
{
final TeiidDataSource teiidDataSource = new TeiidDataSource();
teiidDataSource.setDatabaseName("Chorus");
teiidDataSource.setUser("admin");
teiidDataSource.setPassword("teiid");
try
catch (final SQLException e)
{ throw new TranslatorException(e); } }
else
}