Package org.apache.openjpa.lib.jdbc
Class LoggingConnectionDecorator
java.lang.Object
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
- All Implemented Interfaces:
ConnectionDecorator
A
ConnectionDecorator that creates logging connections and
ReportingSQLExceptions.- Author:
- Marc Prud'hommeaux
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classLogging connection.static interfaceInterface that allows customization of what to do whenSQLWarnings occur. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecorate(Connection conn) Decorate the given connection if desired.getLogs()The log to write to.booleanintbooleanWhether parameter values will be printed in exception messages or in trace.What to do with SQL warnings.What to do with SQL warnings.voidsetPrettyPrint(boolean prettyPrint) If set totrue, pretty-print SQL by running it throughSQLFormatter.prettyPrint(java.lang.Object).voidsetPrettyPrintLineLength(int length) The number of characters to print per line when pretty-printing of SQL is enabled.voidsetPrintParameters(boolean printParameters) voidsetWarningAction(String warningAction) What to do with SQL warnings.voidsetWarningHandler(LoggingConnectionDecorator.SQLWarningHandler warningHandler) What to do with SQL warnings.
-
Constructor Details
-
LoggingConnectionDecorator
public LoggingConnectionDecorator()
-
-
Method Details
-
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint) If set totrue, pretty-print SQL by running it throughSQLFormatter.prettyPrint(java.lang.Object). Iffalse, don't pretty-print, and output SQL logs in a single line. Pretty-printed SQL can be easier for a human to read, but is harder to parse with tools like grep. -
getPrettyPrint
public boolean getPrettyPrint()- See Also:
-
setPrettyPrintLineLength
public void setPrettyPrintLineLength(int length) The number of characters to print per line when pretty-printing of SQL is enabled. Defaults to 60 to provide some space for any ant-related characters on the left of a standard 80-character display. -
getPrettyPrintLineLength
public int getPrettyPrintLineLength()- See Also:
-
getPrintParameters
public boolean getPrintParameters()Whether parameter values will be printed in exception messages or in trace. This is different from trackParameters which controls whether OpenJPA will track parameters internally (visible while debugging and used in batching).
-
setPrintParameters
public void setPrintParameters(boolean printParameters) -
setWarningAction
What to do with SQL warnings. -
getWarningAction
What to do with SQL warnings. -
setWarningHandler
What to do with SQL warnings. -
getWarningHandler
What to do with SQL warnings. -
getLogs
The log to write to. -
decorate
Description copied from interface:ConnectionDecoratorDecorate the given connection if desired.- Specified by:
decoratein interfaceConnectionDecorator- Throws:
SQLException
-