|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.developersupport.SQLDebugger
A helper class that lets you dump the contents of a table into a file in XML format.
Note that this uses direct JDBC calls bypassing persistence. Therefore, no additional persistence flushes are triggered by this class. The current API is very primitive.
Example usage:
// specify the output file name SQLDebugger.startNewFile("txns"); // select the specified columns from a table // and append the result set to /tmp/debug.xml SQLDebugger.dumpTable("after initializing obj and compObj", new String[] {"transaction_id", "master_id", "object_id", "tag"}, "vcx_transactions"); SQLDebugger.dumpTable("after initializing obj and compObj", new String[] {"id", "j_big_integer", "j_big_decimal", "j_string"}, "tx_versioned_datatypes"); // do some computations and dump the data again SQLDebugger.dumpTable("after setting obj to initVersionedTstObj", new String[] {"transaction_id", "master_id", "object_id", "tag"}, "vcx_transactions"); SQLDebugger.dumpTable("after setting obj to initVersionedTstObj", new String[] {"id", "j_big_integer", "j_big_decimal", "j_string"}, "tx_versioned_datatypes"); // close the file SQLDebugger.close();
The .xml files thus generated can be converted to HTML for easier viewing
by using the sql-debugger.sh script.
The script relies on the sql-debugger.xsl stylesheet. and
requires xsltproc
to be installed on your system.
Some of the known numerous shortcomings:
Method Summary | |
static void |
close()
Closes the output file previously opened with startNewFile(String) . |
static void |
dumpQuery(String debugMsg,
String[] columns,
String sqlQuery)
Runs the query sqlQuery and dumps the result to the print
writer in the following format:
|
static void |
dumpTable(String debugMsg,
String[] columns,
String tableName)
|
static void |
startNewFile(String prefix)
Starts a new file for debug output. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void startNewFile(String prefix)
prefix
. The file is created in the directory
specified by the system property "java.io.tmpdir"
.
prefix
- the prefix (initial characters) for the new file name. Must
be at least three characters long.File.createTempFile(String, String)
public static void close()
startNewFile(String)
. If you forget to call this method or if the
application crashes before this method is called, the output file will
miss a closing tag, thus rendering it ill-formed. You can add the missing
tag manually, if you have to.
public static void dumpTable(String debugMsg, String[] columns, String tableName)
dumpQuery(String, String[], String)
public static void dumpQuery(String debugMsg, String[] columns, String sqlQuery)
sqlQuery
and dumps the result to the print
writer in the following format:
<tableName> <row> <column0>value00</column0> <column1>value01</column1> ... </row> <row> <column0>value10</column0> <column1>value11</column1> ... </row> ... </tableName>
debugMsg
- a short message that explains the purpose or
circumstances in which the results of this query were dumped.columns
- the names of columns returned by the querysqlQuery
- the query to execute
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |