Package org.apache.openjpa.lib.jdbc
Class LoggingConnectionDecorator
- java.lang.Object
- 
- org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
 
- 
- All Implemented Interfaces:
- ConnectionDecorator
 
 public class LoggingConnectionDecorator extends java.lang.Object implements ConnectionDecorator AConnectionDecoratorthat creates logging connections andReportingSQLExceptions.- Author:
- Marc Prud'hommeaux
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classLoggingConnectionDecorator.LoggingConnectionLogging connection.static interfaceLoggingConnectionDecorator.SQLWarningHandlerInterface that allows customization of what to do whenSQLWarnings occur.
 - 
Constructor SummaryConstructors Constructor Description LoggingConnectionDecorator()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.Connectiondecorate(java.sql.Connection conn)Decorate the given connection if desired.DataSourceLogsgetLogs()The log to write to.booleangetPrettyPrint()intgetPrettyPrintLineLength()booleangetPrintParameters()Whether parameter values will be printed in exception messages or in trace.java.lang.StringgetWarningAction()What to do with SQL warnings.LoggingConnectionDecorator.SQLWarningHandlergetWarningHandler()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(java.lang.String warningAction)What to do with SQL warnings.voidsetWarningHandler(LoggingConnectionDecorator.SQLWarningHandler warningHandler)What to do with SQL warnings.
 
- 
- 
- 
Method Detail- 
setPrettyPrintpublic 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.
 - 
getPrettyPrintpublic boolean getPrettyPrint() - See Also:
- setPrettyPrint(boolean)
 
 - 
setPrettyPrintLineLengthpublic 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.
 - 
getPrettyPrintLineLengthpublic int getPrettyPrintLineLength() - See Also:
- setPrettyPrintLineLength(int)
 
 - 
getPrintParameterspublic 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). 
 - 
setPrintParameterspublic void setPrintParameters(boolean printParameters) 
 - 
setWarningActionpublic void setWarningAction(java.lang.String warningAction) What to do with SQL warnings.
 - 
getWarningActionpublic java.lang.String getWarningAction() What to do with SQL warnings.
 - 
setWarningHandlerpublic void setWarningHandler(LoggingConnectionDecorator.SQLWarningHandler warningHandler) What to do with SQL warnings.
 - 
getWarningHandlerpublic LoggingConnectionDecorator.SQLWarningHandler getWarningHandler() What to do with SQL warnings.
 - 
getLogspublic DataSourceLogs getLogs() The log to write to.
 - 
decoratepublic java.sql.Connection decorate(java.sql.Connection conn) throws java.sql.SQLExceptionDescription copied from interface:ConnectionDecoratorDecorate the given connection if desired.- Specified by:
- decoratein interface- ConnectionDecorator
- Throws:
- java.sql.SQLException
 
 
- 
 
-