How I can find the SQL queries used in our JSP and EJB to retrieve data from the Oracle 8i Database?
One of the easiest ways to find the SQL statements is to turn on SQL tracing. This can be done with the following statement:
ALTER SESSION SET sql_trace=TRUE;You can have your JSP code issue this statement. Or, you can write an AFTER LOGON trigger to issue it for you.
With this turned on, you will generate many trace files in the directory specified with the USER_DUMP_DEST parameter. These trace files contain your SQL statements.
Another method is to look in V$SQL for SQL statements. But all SQL statements currently in the Shared Pool will be there, no matter who issued them. You'll have to join V$SQL to V$SESSION to determine who issued the queries. Keep in mind that this may not find all queries issued by your application code since some SQL statements may be aged out of the Shared Pool.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.