This one time, at band camp, Neil Blue said:
NB>I am trying to find the debug flags that will let me view the SQL statements
NB>that castor uses. Please could someone point me in the right direction.
Neil,
Are you trying to see all the SQL generated by Castor or just the
SQL that is currently being executed by Castor?
All generated SQL can be viewed by enabling Castor's Logger object
on the JDO object instance. This is demonstrated in the JDO examples
Test object (src/examples/jdo/Test.java):
PrintWriter writer;
...
writer = new Logger( System.out ).setPrefix( "test" );
...
_jdo.setLogWriter( writer );
If you want to see the currently executing SQL, this requires a
small amount of code to be cut in the SQLEngine. The following is
a contextual diff of code that I added quickly to see the currently
executing SQL. Just apply this to the SQLEngine using the patch
utility to see the SQL that Castor is currently executing against
the database:
--------------------------------------------------------------------------------
Index: ./src/main/org/exolab/castor/jdo/engine/SQLEngine.java
===================================================================
RCS file: /cvs/castor/castor/src/main/org/exolab/castor/jdo/engine/SQLEngine.java,v
retrieving revision 1.112
diff -u -r1.112 SQLEngine.java
--- ./src/main/org/exolab/castor/jdo/engine/SQLEngine.java 24 Oct 2002 01:48:42
-0000 1.112
+++ ./src/main/org/exolab/castor/jdo/engine/SQLEngine.java 29 Nov 2002 16:56:05
+-0000
@@ -89,6 +89,7 @@
import org.exolab.castor.persist.spi.Complex;
import java.util.ArrayList;
import java.util.HashSet;
+import java.io.PrintWriter;
/**
@@ -1653,6 +1654,7 @@
public void execute( Object conn, AccessMode accessMode, boolean scrollable )
throws QueryException, PersistenceException
{
+ PrintWriter writer = new Logger( System.out ).setPrefix( "Currently
+executing SQL" );
_lastIdentity = null;
try {
if (scrollable)
@@ -1667,6 +1669,7 @@
_stmt.setObject( i + 1, _values[ i ] );
_values[ i ] = null;
}
+ writer.println( _sql );
_rs = _stmt.executeQuery();
_resultSetDone = false;
} catch ( SQLException except ) {
--------------------------------------------------------------------------------
Bruce
--
perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev