org.apache.openjpa.lib.jdbc
Class LoggingConnectionDecorator

java.lang.Object
  extended by org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
All Implemented Interfaces:
ConnectionDecorator

public class LoggingConnectionDecorator
extends Object
implements ConnectionDecorator

A ConnectionDecorator that creates logging connections and ReportingSQLExceptions.

Author:
Marc Prud'hommeaux

Nested Class Summary
protected  class LoggingConnectionDecorator.LoggingConnection
          Logging connection.
static interface LoggingConnectionDecorator.SQLWarningHandler
          Interface that allows customization of what to do when SQLWarnings occur.
 
Field Summary
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingCallableStatement> loggingCallableStatementImpl
           
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection> loggingConnectionImpl
           
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingDatabaseMetaData> loggingDatabaseMetaDataImpl
           
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingPreparedStatement> loggingPreparedStatementImpl
           
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingResultSet> loggingResultSetImpl
           
(package private) static Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingStatement> loggingStatementImpl
           
 
Constructor Summary
LoggingConnectionDecorator()
           
 
Method Summary
 Connection decorate(Connection conn)
          Decorate the given connection if desired.
 DataSourceLogs getLogs()
          The log to write to.
 boolean getPrettyPrint()
           
 int getPrettyPrintLineLength()
           
 boolean getPrintParameters()
           Whether parameter values will be printed in exception messages or in trace.
 boolean getTrackParameters()
          Whether to track parameters for the purpose of reporting exceptions.
 String getWarningAction()
          What to do with SQL warnings.
 LoggingConnectionDecorator.SQLWarningHandler getWarningHandler()
          What to do with SQL warnings.
 void setPrettyPrint(boolean prettyPrint)
          If set to true, pretty-print SQL by running it through SQLFormatter.prettyPrint(java.lang.Object).
 void setPrettyPrintLineLength(int length)
          The number of characters to print per line when pretty-printing of SQL is enabled.
 void setPrintParameters(boolean printParameters)
           
 void setTrackParameters(boolean trackParameters)
          Whether to track parameters for the purpose of reporting exceptions.
 void setWarningAction(String warningAction)
          What to do with SQL warnings.
 void setWarningHandler(LoggingConnectionDecorator.SQLWarningHandler warningHandler)
          What to do with SQL warnings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggingConnectionImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection> loggingConnectionImpl

loggingResultSetImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingResultSet> loggingResultSetImpl

loggingStatementImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingStatement> loggingStatementImpl

loggingPreparedStatementImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingPreparedStatement> loggingPreparedStatementImpl

loggingCallableStatementImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingCallableStatement> loggingCallableStatementImpl

loggingDatabaseMetaDataImpl

static final Constructor<LoggingConnectionDecorator.LoggingConnection.LoggingDatabaseMetaData> loggingDatabaseMetaDataImpl
Constructor Detail

LoggingConnectionDecorator

public LoggingConnectionDecorator()
Method Detail

setPrettyPrint

public void setPrettyPrint(boolean prettyPrint)
If set to true, pretty-print SQL by running it through SQLFormatter.prettyPrint(java.lang.Object). If false, 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:
setPrettyPrint(boolean)

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:
setPrettyPrintLineLength(int)

setTrackParameters

public void setTrackParameters(boolean trackParameters)

Whether to track parameters for the purpose of reporting exceptions.


getTrackParameters

public boolean getTrackParameters()
Whether to track parameters for the purpose of reporting exceptions.


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

public void setWarningAction(String warningAction)
What to do with SQL warnings.


getWarningAction

public String getWarningAction()
What to do with SQL warnings.


setWarningHandler

public void setWarningHandler(LoggingConnectionDecorator.SQLWarningHandler warningHandler)
What to do with SQL warnings.


getWarningHandler

public LoggingConnectionDecorator.SQLWarningHandler getWarningHandler()
What to do with SQL warnings.


getLogs

public DataSourceLogs getLogs()
The log to write to.


decorate

public Connection decorate(Connection conn)
                    throws SQLException
Description copied from interface: ConnectionDecorator
Decorate the given connection if desired.

Specified by:
decorate in interface ConnectionDecorator
Throws:
SQLException


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.