5 Replies Latest reply on Jul 13, 2016 12:34 PM by rareddy

    Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?


      To establish a bit of context around this question, I need to make audit entries of Teiid JDBC/ODBC SQL statements in an audit table. So, if a user sends the following SQL "Select * from View1" over JDBC/ODBC, I want to log it.


      What I noticed is that Teiid logs out the sql coming in over the JDBC connection like this:

      [NIO2] INFO  [COMMAND_LOG] -START USER COMMAND:startTime=2016-07-12 08:53:35.966requestID=DujbDuBG/XPF.10txID=nullsessionID=DujbDuBG/XPFapplicationName=JDBCprincipal=john@foo.comvdbName=adfcorevdbvdbVersion=2sql=select * from View1

      This logging happens in org.teiid.dqp.internal.process.DQPCore#logMMCommand which gets passed in the RequestWorkItem and obtains the Sql sent in via RequestWorkItem.RequestMessage.sql


      I want to know how I can get access to this sql? I get the following parameters passed into my executionFactory:

      (Command command, ExecutionContext executionContext, RuntimeMetadata metadata, ADFTeiidConnection connection)


      The closest I could come to getting any sort of sql was by drilling thru the executionContext:


      I tried

      ((Table)((CommandContext)executionContext.getCommandContext()).getPlanningObjects().toArray()[1]).getSQLString(), but I just get the name of the View within the model.