-
1. Re: Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?
rareddy Jul 12, 2016 2:19 PM (in response to jrod2016)I guess, let me ask you by what is the usecase? What you sent in as user query may not be same as what you see at the translator level. So, knowing what you trying to achieve we can provide an alternative.
-
2. Re: Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?
jrod2016 Jul 12, 2016 2:43 PM (in response to rareddy)Thanks for responding Ramesh.
The use case is that I'm trying to create an audit entry (in a database table) of what the user sent in. We use Teiid-embedded to provide a JDBC/ODBC interface to our app, so we want to record the original SQL statement that the user sent in.
Regarding what you said about the query the user sent in not being the same as what I see at the translator level; that's exactly what seems to be happening. So, I'm unable to create an audit entry of the users original SQL statement. Is there any part of the framework that I can plug into, to do this?
-
3. Re: Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?
rareddy Jul 13, 2016 12:35 PM (in response to jrod2016)John,
You can do write database appender for Log4J to do the same to capture the same. For a JEE environment we did the same here GitHub - teiid/teiid-extensions: Teiid extensions and utilities
Also see [TEIID-3719] Add Log4j 1 Logger Adapter - JBoss Issue Tracker for more information about using Log4J in embedded.
Note that the audit logging context "org.teiid.COMMAND_LOG", where you can capture both user query log and/or as well as data source query log.
Ramesh..
-
4. Re: Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?
jrod2016 Jul 13, 2016 11:31 AM (in response to rareddy)Based on your suggestion, I subclassed org.teiid.runtime.JBossLogger where I can record my audit log the way I want to. We have already subclassed org.teiid.runtime.EmbeddedServer, so I just set LogManager.setListener to my new Logger class. This way I don't have to process all the log messages if I went the generic appender route - just the ones relevant to Teiid.
Put in my method override here just for reference.
@Override public void log(int level, String context, Object... msg) { if (context.equals("org.teiid.COMMAND_LOG") && msg != null) { for (Object o : msg) { if (o instanceof CommandLogMessage) { CommandLogMessage clm = (CommandLogMessage) o; if (clm.getSql() != null && clm.getApplicationName() != null && !clm.getApplicationName().equals("internal")) { adfDataSourceAuditEntryService .logAuditEntryForCommand(clm.getPrincipal(), clm.getApplicationName(), clm.getSql()); break; } } } } super.log(level, context, msg); }
It would be really cool if the original user query was sent in to the translator in the ExecutionContext. Any reason why this is not the case?
-
5. Re: Teiid-embedded - Does the SQL statement coming in via JDBC/ODBC get passed down to the ExecutionFactory?
rareddy Jul 13, 2016 12:34 PM (in response to jrod2016)COMMAND_LOG has the entry for the original query too, you would need to match them up by the request id in the LogMessage class.