You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC
svn commit: r418401 [5/32] - in /incubator/openjpa/trunk: openjpa-lib/
openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/m...
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,72 +12,72 @@
*/
package org.apache.openjpa.lib.jdbc;
-
/**
- * A listener for all {@link JDBCEvent}s that occur.
- *
- * @see AbstractJDBCListener
- * @author Marc Prud'hommeaux
- * @author Abe White
+ * A listener for all {@link JDBCEvent}s that occur.
+ *
+ * @see AbstractJDBCListener
+ * @author Marc Prud'hommeaux
+ * @author Abe White
*/
public interface JDBCListener {
/**
- * @see JDBCEvent#BEFORE_PREPARE_STATEMENT
+ * @see JDBCEvent#BEFORE_PREPARE_STATEMENT
*/
public void beforePrepareStatement(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_PREPARE_STATEMENT
+ * @see JDBCEvent#AFTER_PREPARE_STATEMENT
*/
public void afterPrepareStatement(JDBCEvent event);
/**
- * @see JDBCEvent#BEFORE_CREATE_STATEMENT
+ * @see JDBCEvent#BEFORE_CREATE_STATEMENT
*/
public void beforeCreateStatement(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_CREATE_STATEMENT
+ * @see JDBCEvent#AFTER_CREATE_STATEMENT
*/
public void afterCreateStatement(JDBCEvent event);
/**
- * @see JDBCEvent#BEFORE_EXECUTE_STATEMENT
+ * @see JDBCEvent#BEFORE_EXECUTE_STATEMENT
*/
public void beforeExecuteStatement(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_EXECUTE_STATEMENT
+ * @see JDBCEvent#AFTER_EXECUTE_STATEMENT
*/
public void afterExecuteStatement(JDBCEvent event);
/**
- * @see JDBCEvent#BEFORE_COMMIT
+ * @see JDBCEvent#BEFORE_COMMIT
*/
public void beforeCommit(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_COMMIT
+ * @see JDBCEvent#AFTER_COMMIT
*/
public void afterCommit(JDBCEvent event);
/**
- * @see JDBCEvent#BEFORE_ROLLBACK
+ * @see JDBCEvent#BEFORE_ROLLBACK
*/
public void beforeRollback(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_ROLLBACK
+ * @see JDBCEvent#AFTER_ROLLBACK
*/
public void afterRollback(JDBCEvent event);
/**
- * @see JDBCEvent#AFTER_CONNECT
+ * @see JDBCEvent#AFTER_CONNECT
*/
public void afterConnect(JDBCEvent event);
/**
- * @see JDBCEvent#BEFORE_CLOSE
+ * @see JDBCEvent#BEFORE_CLOSE
*/
public void beforeClose(JDBCEvent event);
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,28 +12,24 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.log.*;
-
import java.io.*;
-
import java.math.*;
-
import java.sql.*;
import java.sql.Date;
-
import java.util.*;
-
import javax.sql.*;
-
+import org.apache.openjpa.lib.log.*;
/**
- * A {@link ConnectionDecorator} that creates logging connections and
- * {@link ReportingSQLException}s.
- *
- * @author Marc Prud'hommeaux
- * @nojavadoc */
+ * A {@link ConnectionDecorator} that creates logging connections and
+ * {@link ReportingSQLException}s.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
public class LoggingConnectionDecorator implements ConnectionDecorator {
private static final String SEP = System.getProperty("line.separator");
+
private static final int WARN_IGNORE = 0;
private static final int WARN_LOG_TRACE = 1;
private static final int WARN_LOG_INFO = 2;
@@ -45,7 +38,6 @@
private static final int WARN_THROW = 5;
private static final int WARN_HANDLE = 6;
private static final String[] WARNING_ACTIONS = new String[7];
-
static {
WARNING_ACTIONS[WARN_IGNORE] = "ignore";
WARNING_ACTIONS[WARN_LOG_TRACE] = "trace";
@@ -65,101 +57,94 @@
private boolean _trackParameters = true;
/**
- * If set to <code>true</code>, pretty-print SQL by running it
- * through {@link SQLFormatter#prettyPrint}. If
- * <code>false</code>, 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.
+ * If set to <code>true</code>, pretty-print SQL by running it
+ * through {@link SQLFormatter#prettyPrint}. If
+ * <code>false</code>, 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.
*/
public void setPrettyPrint(boolean prettyPrint) {
_prettyPrint = prettyPrint;
-
- if ((_formatter == null) && _prettyPrint) {
+ if (_formatter == null && _prettyPrint) {
_formatter = new SQLFormatter();
_formatter.setLineLength(_prettyPrintLineLength);
- } else if (!_prettyPrint) {
+ } else if (!_prettyPrint)
_formatter = null;
- }
}
/**
- * @see {@link #setPrettyPrint}
+ * @see {@link #setPrettyPrint}
*/
public boolean getPrettyPrint() {
return _prettyPrint;
}
/**
- * 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.
+ * 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.
*/
public void setPrettyPrintLineLength(int length) {
_prettyPrintLineLength = length;
-
- if (_formatter != null) {
+ if (_formatter != null)
_formatter.setLineLength(length);
- }
}
/**
- * @see {@link #setPrettyPrintLineLength}
+ * @see {@link #setPrettyPrintLineLength}
*/
public int getPrettyPrintLineLength() {
return _prettyPrintLineLength;
}
/**
- * Whether to track parameters for the purposes of reporting exceptions.
+ * Whether to track parameters for the purposes of reporting exceptions.
*/
public void setTrackParameters(boolean trackParameters) {
_trackParameters = trackParameters;
}
/**
- * Whether to track parameters for the purposes of reporting exceptions.
+ * Whether to track parameters for the purposes of reporting exceptions.
*/
public boolean getTrackParameters() {
return _trackParameters;
}
/**
- * What to do with SQL warnings.
+ * What to do with SQL warnings.
*/
public void setWarningAction(String warningAction) {
int index = Arrays.asList(WARNING_ACTIONS).indexOf(warningAction);
-
- if (index < 0) {
+ if (index < 0)
index = WARN_IGNORE;
- }
-
_warningAction = index;
}
/**
- * What to do with SQL warnings.
+ * What to do with SQL warnings.
*/
public String getWarningAction() {
return WARNING_ACTIONS[_warningAction];
}
/**
- * What to do with SQL warnings.
+ * What to do with SQL warnings.
*/
public void setWarningHandler(SQLWarningHandler warningHandler) {
_warningHandler = warningHandler;
}
/**
- * What to do with SQL warnings.
+ * What to do with SQL warnings.
*/
public SQLWarningHandler getWarningHandler() {
return _warningHandler;
}
/**
- * The log to write to.
+ * The log to write to.
*/
public DataSourceLogs getLogs() {
return _logs;
@@ -170,33 +155,33 @@
}
private SQLException wrap(SQLException sqle, Statement stmnt) {
- if (sqle instanceof ReportingSQLException) {
- return (ReportingSQLException) sqle;
- }
+ if (sqle instanceof ReportingSQLException)
+ return(ReportingSQLException)sqle;
return new ReportingSQLException(sqle, stmnt);
}
private SQLException wrap(SQLException sqle, String sql) {
- if (sqle instanceof ReportingSQLException) {
- return (ReportingSQLException) sqle;
- }
+ if (sqle instanceof ReportingSQLException)
+ return(ReportingSQLException)sqle;
return new ReportingSQLException(sqle, sql);
}
- private static String getExceptionMessage(SQLException sqle, Statement stmnt) {
+ private static String getExceptionMessage(SQLException sqle,
+ Statement stmnt) {
try {
- return sqle.getMessage() + " {" + stmnt + "} " + "[code=" +
- sqle.getErrorCode() + ", state=" + sqle.getSQLState() + "]";
+ return sqle.getMessage() + " {" + stmnt + "} "
+ + "[code=" + sqle.getErrorCode() + ", state="
+ + sqle.getSQLState() + "]";
} catch (Throwable t) {
return sqle.getMessage();
}
}
/**
- * Interface that allows customization of what to do when
- * {@link SQLWarning}s occur.
+ * Interface that allows customization of what to do when
+ * {@link SQLWarning}s occur.
*/
public static interface SQLWarningHandler {
public void handleWarning(SQLWarning warning) throws SQLException;
@@ -211,7 +196,6 @@
throws SQLException {
try {
PreparedStatement stmnt = super.prepareStatement(sql, false);
-
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
@@ -221,26 +205,22 @@
protected PreparedStatement prepareStatement(String sql, int rsType,
int rsConcur, boolean wrap) throws SQLException {
try {
- PreparedStatement stmnt = super.prepareStatement(sql, rsType,
- rsConcur, false);
-
+ PreparedStatement stmnt = super.prepareStatement
+ (sql, rsType, rsConcur, false);
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
}
}
- protected Statement createStatement(boolean wrap)
- throws SQLException {
+ protected Statement createStatement(boolean wrap) throws SQLException {
Statement stmnt = super.createStatement(false);
-
return new LoggingStatement(stmnt);
}
protected Statement createStatement(int type, int concurrency,
boolean wrap) throws SQLException {
Statement stmnt = super.createStatement(type, concurrency, false);
-
return new LoggingStatement(stmnt);
}
@@ -249,11 +229,10 @@
try {
super.commit();
- } finally {
- if (_logs.isJDBCEnabled()) {
+ }
+ finally {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("commit", start, this);
- }
-
handleSQLWarning();
}
}
@@ -263,11 +242,10 @@
try {
super.rollback();
- } finally {
- if (_logs.isJDBCEnabled()) {
+ }
+ finally {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("rollback", start, this);
- }
-
handleSQLWarning();
}
}
@@ -277,82 +255,71 @@
try {
super.close();
- } finally {
- if (_logs.isJDBCEnabled()) {
+ }
+ finally {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("close", start, this);
- }
}
}
public Savepoint setSavepoint() throws SQLException {
long start = System.currentTimeMillis();
-
try {
return super.setSavepoint();
- } finally {
- if (_logs.isJDBCEnabled()) {
+ }
+ finally {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("savepoint", start, this);
- }
-
handleSQLWarning();
}
}
public Savepoint setSavepoint(String name) throws SQLException {
long start = System.currentTimeMillis();
-
try {
return super.setSavepoint(name);
- } finally {
- if (_logs.isJDBCEnabled()) {
+ }
+ finally {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("savepoint: " + name, start, this);
- }
-
handleSQLWarning();
}
}
public void rollback(Savepoint savepoint) throws SQLException {
long start = System.currentTimeMillis();
-
try {
super.rollback(savepoint);
- } finally {
+ }
+ finally {
if (_logs.isJDBCEnabled()) {
String name = null;
-
try {
name = savepoint.getSavepointName();
} catch (SQLException sqe) {
name = String.valueOf(savepoint.getSavepointId());
}
-
_logs.logJDBC("rollback: " + name, start, this);
}
-
handleSQLWarning();
}
}
- public void releaseSavepoint(Savepoint savepoint)
- throws SQLException {
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
long start = System.currentTimeMillis();
-
try {
super.releaseSavepoint(savepoint);
- } finally {
+ }
+ finally {
if (_logs.isJDBCEnabled()) {
String name = null;
-
try {
name = savepoint.getSavepointName();
} catch (SQLException sqe) {
name = String.valueOf(savepoint.getSavepointId());
}
-
_logs.logJDBC("release: " + name, start, this);
}
-
handleSQLWarning();
}
}
@@ -361,9 +328,8 @@
int resultSetConcurrency, int resultSetHoldability, boolean wrap)
throws SQLException {
Statement stmnt = super.createStatement(resultSetType,
- resultSetConcurrency, resultSetHoldability, false);
+ resultSetConcurrency, resultSetHoldability, false);
handleSQLWarning();
-
return new LoggingStatement(stmnt);
}
@@ -371,11 +337,10 @@
int resultSetType, int resultSetConcurrency,
int resultSetHoldability, boolean wrap) throws SQLException {
try {
- PreparedStatement stmnt = super.prepareStatement(sql,
- resultSetType, resultSetConcurrency,
- resultSetHoldability, false);
+ PreparedStatement stmnt = super.prepareStatement
+ (sql, resultSetType, resultSetConcurrency,
+ resultSetHoldability, false);
handleSQLWarning();
-
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
@@ -385,10 +350,9 @@
protected PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys, boolean wrap) throws SQLException {
try {
- PreparedStatement stmnt = super.prepareStatement(sql,
- autoGeneratedKeys, false);
+ PreparedStatement stmnt = super.prepareStatement
+ (sql, autoGeneratedKeys, false);
handleSQLWarning();
-
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
@@ -398,10 +362,9 @@
protected PreparedStatement prepareStatement(String sql,
int[] columnIndexes, boolean wrap) throws SQLException {
try {
- PreparedStatement stmnt = super.prepareStatement(sql,
- columnIndexes, false);
+ PreparedStatement stmnt = super.prepareStatement
+ (sql, columnIndexes, false);
handleSQLWarning();
-
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
@@ -411,139 +374,109 @@
protected PreparedStatement prepareStatement(String sql,
String[] columnNames, boolean wrap) throws SQLException {
try {
- PreparedStatement stmnt = super.prepareStatement(sql,
- columnNames, false);
+ PreparedStatement stmnt = super.prepareStatement
+ (sql, columnNames, false);
handleSQLWarning();
-
return new LoggingPreparedStatement(stmnt, sql);
} catch (SQLException se) {
throw wrap(se, sql);
}
}
- protected DatabaseMetaData getMetaData(boolean wrap)
- throws SQLException {
+ protected DatabaseMetaData getMetaData(boolean wrap) throws SQLException {
return new LoggingDatabaseMetaData(super.getMetaData(false));
}
/**
- * Handle any {@link SQLWarning}s on the current {@link Connection}.
- *
- * @see #handleSQLWarning(SQLWarning)
+ * Handle any {@link SQLWarning}s on the current {@link Connection}.
+ *
+ * @see #handleSQLWarning(SQLWarning)
*/
private void handleSQLWarning() throws SQLException {
- if (_warningAction == WARN_IGNORE) {
+ if (_warningAction == WARN_IGNORE)
return;
- }
try {
handleSQLWarning(getWarnings());
- } finally {
+ }
+ finally {
clearWarnings();
}
}
/**
- * Handle any {@link SQLWarning}s on the specified {@link Statement}.
- *
- * @see #handleSQLWarning(SQLWarning)
+ * Handle any {@link SQLWarning}s on the specified {@link Statement}.
+ *
+ * @see #handleSQLWarning(SQLWarning)
*/
- private void handleSQLWarning(Statement stmnt)
- throws SQLException {
- if (_warningAction == WARN_IGNORE) {
+ private void handleSQLWarning(Statement stmnt) throws SQLException {
+ if (_warningAction == WARN_IGNORE)
return;
- }
try {
handleSQLWarning(stmnt.getWarnings());
- } finally {
+ }
+ finally {
stmnt.clearWarnings();
}
}
/**
- * Handle any {@link SQLWarning}s on the specified {@link ResultSet}.
- *
- * @see #handleSQLWarning(SQLWarning)
+ * Handle any {@link SQLWarning}s on the specified {@link ResultSet}.
+ *
+ * @see #handleSQLWarning(SQLWarning)
*/
private void handleSQLWarning(ResultSet rs) throws SQLException {
- if (_warningAction == WARN_IGNORE) {
+ if (_warningAction == WARN_IGNORE)
return;
- }
try {
handleSQLWarning(rs.getWarnings());
- } finally {
+ }
+ finally {
rs.clearWarnings();
}
}
/**
- * Handle the specified {@link SQLWarning} depending on the
- * setting of the {@link #setWarningAction} attribute.
- *
- * @param warning the warning to handle
+ * Handle the specified {@link SQLWarning} depending on the
+ * setting of the {@link #setWarningAction} attribute.
+ *
+ * @param warning the warning to handle
*/
void handleSQLWarning(SQLWarning warning) throws SQLException {
- if (warning == null) {
+ if (warning == null)
return;
- }
-
- if (_warningAction == WARN_IGNORE) {
+ if (_warningAction == WARN_IGNORE)
return;
- }
Log log = _logs.getJDBCLog();
-
- for (; warning != null; warning = warning.getNextWarning()) {
+ for ( ; warning != null; warning = warning.getNextWarning()) {
switch (_warningAction) {
case WARN_LOG_TRACE:
-
- if (log.isTraceEnabled()) {
+ if (log.isTraceEnabled())
log.trace(warning);
- }
-
break;
-
case WARN_LOG_INFO:
-
- if (log.isInfoEnabled()) {
+ if (log.isInfoEnabled())
log.info(warning);
- }
-
break;
-
case WARN_LOG_WARN:
-
- if (log.isWarnEnabled()) {
+ if (log.isWarnEnabled())
log.warn(warning);
- }
-
break;
-
case WARN_LOG_ERROR:
-
- if (log.isErrorEnabled()) {
+ if (log.isErrorEnabled())
log.error(warning);
- }
-
break;
-
case WARN_THROW:
-
// just throw it as if it were a SQLException
throw warning;
-
case WARN_HANDLE:
-
- if (_warningHandler != null) {
+ if (_warningHandler != null)
_warningHandler.handleWarning(warning);
- }
-
break;
-
default:
-
// ignore
break;
}
@@ -558,114 +491,102 @@
public ResultSet getBestRowIdentifier(String catalog,
String schema, String table, int scope, boolean nullable)
throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getBestRowIdentifier: " + catalog + ", " +
- schema + ", " + table, LoggingConnection.this);
- }
-
- return super.getBestRowIdentifier(catalog, schema, table,
- scope, nullable);
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getBestRowIdentifier: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
+ return super.getBestRowIdentifier(catalog, schema,
+ table, scope, nullable);
}
public ResultSet getCatalogs() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getCatalogs", LoggingConnection.this);
- }
-
return super.getCatalogs();
}
public ResultSet getColumnPrivileges(String catalog, String schema,
- String table, String columnNamePattern)
- throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getColumnPrivileges: " + catalog + ", " +
- schema + ", " + table, LoggingConnection.this);
- }
-
- return super.getColumnPrivileges(catalog, schema, table,
- columnNamePattern);
+ String table, String columnNamePattern) throws SQLException {
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getColumnPrivileges: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
+ return super.getColumnPrivileges(catalog, schema,
+ table, columnNamePattern);
}
public ResultSet getColumns(String catalog, String schemaPattern,
String tableNamePattern, String columnNamePattern)
throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getColumns: " + catalog + ", " +
- schemaPattern + ", " + tableNamePattern + ", " +
- columnNamePattern, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getColumns: "
+ + catalog + ", " + schemaPattern + ", "
+ + tableNamePattern + ", " + columnNamePattern,
+ LoggingConnection.this);
return super.getColumns(catalog, schemaPattern,
tableNamePattern, columnNamePattern);
}
public ResultSet getCrossReference(String primaryCatalog,
String primarySchema, String primaryTable,
- String foreignCatalog, String foreignSchema, String foreignTable)
- throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getCrossReference: " + primaryCatalog +
- ", " + primarySchema + ", " + primaryTable + ", " +
- foreignCatalog + ", " + foreignSchema + ", " +
- foreignSchema, LoggingConnection.this);
- }
-
+ String foreignCatalog, String foreignSchema,
+ String foreignTable) throws SQLException {
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getCrossReference: "
+ + primaryCatalog + ", " + primarySchema + ", "
+ + primaryTable + ", " + foreignCatalog + ", "
+ + foreignSchema + ", " + foreignSchema,
+ LoggingConnection.this);
return super.getCrossReference(primaryCatalog, primarySchema,
primaryTable, foreignCatalog, foreignSchema, foreignTable);
}
public ResultSet getExportedKeys(String catalog, String schema,
String table) throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getExportedKeys: " + catalog + ", " +
- schema + ", " + table, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getExportedKeys: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
return super.getExportedKeys(catalog, schema, table);
}
public ResultSet getImportedKeys(String catalog, String schema,
String table) throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getImportedKeys: " + catalog + ", " +
- schema + ", " + table, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getImportedKeys: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
return super.getImportedKeys(catalog, schema, table);
}
public ResultSet getIndexInfo(String catalog, String schema,
String table, boolean unique, boolean approximate)
throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getIndexInfo: " + catalog + ", " + schema +
- ", " + table, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getIndexInfo: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
return super.getIndexInfo(catalog, schema, table, unique,
approximate);
}
public ResultSet getPrimaryKeys(String catalog, String schema,
String table) throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getPrimaryKeys: " + catalog + ", " + schema +
- ", " + table, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getPrimaryKeys: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
return super.getPrimaryKeys(catalog, schema, table);
}
public ResultSet getProcedureColumns(String catalog,
String schemaPattern, String procedureNamePattern,
String columnNamePattern) throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getProcedureColumns: " + catalog + ", " +
- schemaPattern + ", " + procedureNamePattern + ", " +
- columnNamePattern, LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getProcedureColumns: "
+ + catalog + ", " + schemaPattern + ", "
+ + procedureNamePattern + ", " + columnNamePattern,
+ LoggingConnection.this);
return super.getProcedureColumns(catalog, schemaPattern,
procedureNamePattern, columnNamePattern);
}
@@ -673,88 +594,72 @@
public ResultSet getProcedures(String catalog,
String schemaPattern, String procedureNamePattern)
throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getProcedures: " + catalog + ", " +
- schemaPattern + ", " + procedureNamePattern,
- LoggingConnection.this);
- }
-
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getProcedures: "
+ + catalog + ", " + schemaPattern + ", "
+ + procedureNamePattern, LoggingConnection.this);
return super.getProcedures(catalog, schemaPattern,
procedureNamePattern);
}
public ResultSet getSchemas() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getSchemas", LoggingConnection.this);
- }
-
return super.getSchemas();
}
public ResultSet getTablePrivileges(String catalog,
String schemaPattern, String tableNamePattern)
throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getTablePrivileges", LoggingConnection.this);
- }
-
return super.getTablePrivileges(catalog, schemaPattern,
tableNamePattern);
}
public ResultSet getTables(String catalog, String schemaPattern,
- String tableNamePattern, String[] types)
- throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getTables: " + catalog + ", " +
- schemaPattern + ", " + tableNamePattern,
- LoggingConnection.this);
- }
-
+ String tableNamePattern, String[] types) throws SQLException {
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getTables: "
+ + catalog + ", " + schemaPattern + ", "
+ + tableNamePattern, LoggingConnection.this);
return super.getTables(catalog, schemaPattern,
tableNamePattern, types);
}
public ResultSet getTableTypes() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getTableTypes", LoggingConnection.this);
- }
-
return super.getTableTypes();
}
public ResultSet getTypeInfo() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getTypeInfo", LoggingConnection.this);
- }
-
return super.getTypeInfo();
}
public ResultSet getUDTs(String catalog, String schemaPattern,
String typeNamePattern, int[] types) throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("getUDTs", LoggingConnection.this);
- }
-
- return super.getUDTs(catalog, schemaPattern, typeNamePattern,
- types);
+ return super.getUDTs(catalog, schemaPattern,
+ typeNamePattern, types);
}
- public ResultSet getVersionColumns(String catalog, String schema,
- String table) throws SQLException {
- if (_logs.isJDBCEnabled()) {
- _logs.logJDBC("getVersionColumns: " + catalog + ", " +
- schema + ", " + table, LoggingConnection.this);
- }
-
+ public ResultSet getVersionColumns(String catalog,
+ String schema, String table) throws SQLException {
+ if (_logs.isJDBCEnabled())
+ _logs.logJDBC("getVersionColumns: "
+ + catalog + ", " + schema + ", " + table,
+ LoggingConnection.this);
return super.getVersionColumns(catalog, schema, table);
}
}
/**
- * Statement wrapper that logs SQL to the parent data source and
- * remembers the last piece of SQL to be executed on it.
+ * Statement wrapper that logs SQL to the parent data source and
+ * remembers the last piece of SQL to be executed on it.
*/
private class LoggingStatement extends DelegatingStatement {
private String _sql = null;
@@ -766,7 +671,6 @@
public void appendInfo(StringBuffer buf) {
if (_sql != null) {
buf.append(" ");
-
if (_formatter != null) {
buf.append(SEP);
buf.append(_formatter.prettyPrint(_sql));
@@ -777,18 +681,15 @@
}
protected ResultSet wrapResult(ResultSet rs, boolean wrap) {
- if (!wrap || (rs == null)) {
+ if (!wrap || rs == null)
return super.wrapResult(rs, wrap);
- }
-
return new LoggingResultSet(rs, this);
}
public void cancel() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("cancel " + this + ": " + _sql,
LoggingConnection.this);
- }
super.cancel();
}
@@ -798,17 +699,15 @@
long start = System.currentTimeMillis();
_sql = sql;
-
try {
return super.executeQuery(sql, wrap);
} catch (SQLException se) {
throw wrap(se, LoggingStatement.this);
- } finally {
- if (_logs.isSQLEnabled()) {
+ }
+ finally {
+ if (_logs.isSQLEnabled())
_logs.logSQL("executing " + this, start,
LoggingConnection.this);
- }
-
handleSQLWarning(LoggingStatement.this);
}
}
@@ -817,17 +716,15 @@
long start = System.currentTimeMillis();
_sql = sql;
-
try {
return super.executeUpdate(sql);
} catch (SQLException se) {
throw wrap(se, LoggingStatement.this);
- } finally {
- if (_logs.isSQLEnabled()) {
+ }
+ finally {
+ if (_logs.isSQLEnabled())
_logs.logSQL("executing " + this, start,
LoggingConnection.this);
- }
-
handleSQLWarning(LoggingStatement.this);
}
}
@@ -836,17 +733,15 @@
long start = System.currentTimeMillis();
_sql = sql;
-
try {
return super.execute(sql);
} catch (SQLException se) {
throw wrap(se, LoggingStatement.this);
- } finally {
- if (_logs.isSQLEnabled()) {
+ }
+ finally {
+ if (_logs.isSQLEnabled())
_logs.logSQL("executing " + this, start,
LoggingConnection.this);
- }
-
handleSQLWarning(LoggingStatement.this);
}
}
@@ -865,10 +760,8 @@
}
protected ResultSet wrapResult(ResultSet rs, boolean wrap) {
- if (!wrap || (rs == null)) {
+ if (!wrap || rs == null)
return super.wrapResult(rs, wrap);
- }
-
return new LoggingResultSet(rs, this);
}
@@ -880,7 +773,8 @@
return super.executeQuery(sql, wrap);
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
@@ -894,7 +788,8 @@
return super.executeUpdate(sql);
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
@@ -908,36 +803,38 @@
return super.execute(sql);
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
}
}
- protected ResultSet executeQuery(boolean wrap)
- throws SQLException {
+ protected ResultSet executeQuery(boolean wrap) throws SQLException {
long start = System.currentTimeMillis();
try {
return super.executeQuery(wrap);
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
}
}
- public int executeUpdate() throws SQLException {
+ public int executeUpdate () throws SQLException {
long start = System.currentTimeMillis();
try {
return super.executeUpdate();
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
@@ -955,20 +852,17 @@
// parameter set to be the index of the failed
// statement so that the ReportingSQLException will
// show the correct param
- if (se instanceof BatchUpdateException &&
- (_paramBatch != null) && shouldTrackParameters()) {
- int[] count = ((BatchUpdateException) se).getUpdateCounts();
-
- if ((count != null) &&
- (count.length <= _paramBatch.size())) {
+ if (se instanceof BatchUpdateException
+ && _paramBatch != null && shouldTrackParameters()) {
+ int[] count = ((BatchUpdateException)se).
+ getUpdateCounts();
+ if (count != null && count.length <= _paramBatch.size()) {
int index = -1;
-
for (int i = 0; i < count.length; i++) {
// -3 is Statement.STATEMENT_FAILED, but is
// only available in JDK 1.4+
if (count[i] == -3) {
index = i;
-
break;
}
}
@@ -976,19 +870,17 @@
// no -3 element: it may be that the server stopped
// processing, so the size of the count will be
// the index
- if (index == -1) {
+ if (index == -1)
index = count.length + 1;
- }
// set the current params to the saved values
- if (index < _paramBatch.size()) {
- _params = (List) _paramBatch.get(index);
- }
+ if (index < _paramBatch.size())
+ _params = (List)_paramBatch.get(index);
}
}
-
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing batch", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
@@ -1002,7 +894,8 @@
return super.execute();
} catch (SQLException se) {
throw wrap(se, LoggingPreparedStatement.this);
- } finally {
+ }
+ finally {
log("executing", start);
clearLogParameters(true);
handleSQLWarning(LoggingPreparedStatement.this);
@@ -1010,10 +903,9 @@
}
public void cancel() throws SQLException {
- if (_logs.isJDBCEnabled()) {
+ if (_logs.isJDBCEnabled())
_logs.logJDBC("cancel " + this + ": " + _sql,
LoggingConnection.this);
- }
super.cancel();
}
@@ -1030,7 +922,7 @@
public void setByte(int i, byte b) throws SQLException {
setLogParameter(i, b);
- super.setByte(i, b);
+ super.setByte(i,b);
}
public void setShort(int i, short s) throws SQLException {
@@ -1058,8 +950,7 @@
super.setDouble(i, d);
}
- public void setBigDecimal(int i, BigDecimal bd)
- throws SQLException {
+ public void setBigDecimal(int i, BigDecimal bd) throws SQLException {
setLogParameter(i, "BigDecimal", bd);
super.setBigDecimal(i, bd);
}
@@ -1084,8 +975,7 @@
super.setTime(i, t);
}
- public void setTimestamp(int i, Timestamp t)
- throws SQLException {
+ public void setTimestamp(int i, Timestamp t) throws SQLException {
setLogParameter(i, "Timestamp", t);
super.setTimestamp(i, t);
}
@@ -1119,8 +1009,7 @@
super.setObject(i1, o, i2, i3);
}
- public void setObject(int i1, Object o, int i2)
- throws SQLException {
+ public void setObject(int i1, Object o, int i2) throws SQLException {
setLogParameter(i1, "Object", o);
super.setObject(i1, o, i2);
}
@@ -1135,21 +1024,18 @@
try {
super.addBatch();
-
if (shouldTrackParameters()) {
// make sure our list is initialized
- if (_paramBatch == null) {
+ if (_paramBatch == null)
_paramBatch = new ArrayList();
- }
-
// copy parameters since they will be re-used
- if (_params != null) {
+ if (_params != null)
_paramBatch.add(new ArrayList(_params));
- } else {
+ else
_paramBatch.add(null);
- }
}
- } finally {
+ }
+ finally {
log("batching", start);
}
}
@@ -1184,14 +1070,12 @@
return super.getMetaData();
}
- public void setDate(int i, Date d, Calendar c)
- throws SQLException {
+ public void setDate(int i, Date d, Calendar c) throws SQLException {
setLogParameter(i, "Date", d);
super.setDate(i, d, c);
}
- public void setTime(int i, Time t, Calendar c)
- throws SQLException {
+ public void setTime(int i, Time t, Calendar c) throws SQLException {
setLogParameter(i, "Time", t);
super.setTime(i, t, c);
}
@@ -1202,15 +1086,13 @@
super.setTimestamp(i, t, c);
}
- public void setNull(int i1, int i2, String s)
- throws SQLException {
+ public void setNull(int i1, int i2, String s) throws SQLException {
setLogParameter(i1, "null", null);
super.setNull(i1, i2, s);
}
protected void appendInfo(StringBuffer buf) {
buf.append(" ");
-
if (_formatter != null) {
buf.append(SEP);
buf.append(_formatter.prettyPrint(_sql));
@@ -1220,47 +1102,35 @@
}
StringBuffer paramBuf = null;
-
- if ((_params != null) && !_params.isEmpty()) {
+ if (_params != null && !_params.isEmpty()) {
paramBuf = new StringBuffer();
-
for (Iterator itr = _params.iterator(); itr.hasNext();) {
paramBuf.append(itr.next());
-
- if (itr.hasNext()) {
+ if (itr.hasNext())
paramBuf.append(", ");
- }
}
}
if (paramBuf != null) {
- if (!_prettyPrint) {
+ if (!_prettyPrint)
buf.append(" ");
- }
-
- buf.append("[params=").append(paramBuf.toString())
- .append("]");
+ buf.append("[params=").
+ append(paramBuf.toString()).append("]");
}
-
super.appendInfo(buf);
}
- private void log(String msg, long startTime)
- throws SQLException {
- if (_logs.isSQLEnabled()) {
+ private void log(String msg, long startTime) throws SQLException {
+ if (_logs.isSQLEnabled())
_logs.logSQL(msg + " " + this, startTime,
LoggingConnection.this);
- }
}
private void clearLogParameters(boolean batch) {
- if (_params != null) {
+ if (_params != null)
_params.clear();
- }
-
- if (batch && (_paramBatch != null)) {
+ if (batch && _paramBatch != null)
_paramBatch.clear();
- }
}
private boolean shouldTrackParameters() {
@@ -1268,65 +1138,52 @@
}
private void setLogParameter(int index, boolean val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(boolean) " + val);
- }
}
private void setLogParameter(int index, byte val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(byte) " + val);
- }
}
private void setLogParameter(int index, double val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(double) " + val);
- }
}
private void setLogParameter(int index, float val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(float) " + val);
- }
}
private void setLogParameter(int index, int val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(int) " + val);
- }
}
private void setLogParameter(int index, long val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(long) " + val);
- }
}
private void setLogParameter(int index, short val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(short) " + val);
- }
}
private void setLogParameter(int index, String type, Object val) {
- if (shouldTrackParameters()) {
+ if (shouldTrackParameters())
setLogParameter(index, "(" + type + ") " + val);
- }
}
private void setLogParameter(int index, String val) {
- if (_params == null) {
+ if (_params == null)
_params = new ArrayList();
- }
-
while (_params.size() < index)
_params.add(null);
-
- if (val.length() > 80) {
+ if (val.length() > 80)
val = val.substring(0, 77) + "...";
- }
-
_params.set(index - 1, val);
}
}
@@ -1339,7 +1196,8 @@
public boolean next() throws SQLException {
try {
return super.next();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1347,7 +1205,8 @@
public void close() throws SQLException {
try {
super.close();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1355,7 +1214,8 @@
public void beforeFirst() throws SQLException {
try {
super.beforeFirst();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1363,7 +1223,8 @@
public void afterLast() throws SQLException {
try {
super.afterLast();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1371,7 +1232,8 @@
public boolean first() throws SQLException {
try {
return super.first();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1379,7 +1241,8 @@
public boolean last() throws SQLException {
try {
return super.last();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1387,7 +1250,8 @@
public boolean absolute(int a) throws SQLException {
try {
return super.absolute(a);
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1395,7 +1259,8 @@
public boolean relative(int a) throws SQLException {
try {
return super.relative(a);
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
@@ -1403,7 +1268,8 @@
public boolean previous() throws SQLException {
try {
return super.previous();
- } finally {
+ }
+ finally {
handleSQLWarning(LoggingResultSet.this);
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,13 +14,13 @@
import java.sql.*;
-
/**
- * <p>A {@link SQLException} that contains information about
- * the {@link Statement} SQL that caused the exception.</p>
- *
- * @author Marc Prud'hommeaux
- * @nojavadoc */
+ * A {@link SQLException} that contains information about
+ * the {@link Statement} SQL that caused the exception.
+ *
+ * @author Marc Prud'hommeaux
+ * @nojavadoc
+ */
public class ReportingSQLException extends SQLException {
private final transient Statement _stmnt;
private final SQLException _sqle;
@@ -44,21 +41,21 @@
}
/**
- * Returns the SQL state of the underlying {@link SQLException}.
+ * Returns the SQL state of the underlying {@link SQLException}.
*/
public String getSQLState() {
return _sqle.getSQLState();
}
/**
- * Returns the error code of the underlying {@link SQLException}.
+ * Returns the error code of the underlying {@link SQLException}.
*/
public int getErrorCode() {
return _sqle.getErrorCode();
}
/**
- * Returns the {@link Statement} that caused the exception.
+ * Returns the {@link Statement} that caused the exception.
*/
public Statement getStatement() {
return _stmnt;
@@ -67,18 +64,21 @@
private static String getExceptionMessage(SQLException sqle,
Statement stmnt, String sql) {
try {
- if (stmnt != null) {
- return sqle.getMessage() + " {" + stmnt + "} " + "[code=" +
- sqle.getErrorCode() + ", state=" + sqle.getSQLState() + "]";
- } else if (sql != null) {
- return sqle.getMessage() + " {" + sql + "} " + "[code=" +
- sqle.getErrorCode() + ", state=" + sqle.getSQLState() + "]";
- } else {
- return sqle.getMessage() + " " + "[code=" +
- sqle.getErrorCode() + ", state=" + sqle.getSQLState() + "]";
- }
+ if (stmnt != null)
+ return sqle.getMessage() + " {" + stmnt + "} "
+ + "[code=" + sqle.getErrorCode() + ", state="
+ + sqle.getSQLState() + "]";
+ else if (sql != null)
+ return sqle.getMessage() + " {" + sql + "} "
+ + "[code=" + sqle.getErrorCode() + ", state="
+ + sqle.getSQLState() + "]";
+ else
+ return sqle.getMessage() + " "
+ + "[code=" + sqle.getErrorCode() + ", state="
+ + sqle.getSQLState() + "]";
} catch (Throwable t) {
return sqle.getMessage();
}
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,47 +14,31 @@
import java.util.*;
-
/*
- * Lots of this could be abstracted out into a word-wrapping class.
+ * Lots of this could be abstracted out into a word-wrapping class.
*/
/**
- * <p>Converts single-line SQL strings into nicely-formatted
- * multi-line, indented statements.</p>
- *
- <p>Example:
- <code>SELECT * from PERSON t0, COMPANY t1 WHERE t0.ID = 10 AND \
-t0.COMPANY_ID = t1.ID AND t1.NAME = 'OpenJPA'</code>
- becomes
- <code>SELECT *
- FROM PERSON t0, COMPANY t1
- WHERE t0.ID = 10 AND t0.COMPANY_ID = t1.ID AND t1.NAME = 'OpenJPA'\
-</code>
- and
- <code>INSERT INTO PERSON VALUES ('Patrick', 'Linskey', 'OpenJPA', \
-'202 595 2064 x1111')</code>
- becomes
- <code>INSERT INTO PERSON VALUES ('Patrick', 'Linskey', 'OpenJPA', '202
- 595 2064 x1111')</code>
- etc.</p>
- *
- * @author Patrick Linskey
+ * Converts single-line SQL strings into nicely-formatted
+ * multi-line, indented statements.
+ * Example: from PERSON t0, COMPANY t1 WHERE t0.ID = 10 AND \
+ t0.COMPANY_ID = t1.ID AND t1.NAME = 'OpenJPA'</code>
+ becomes
+ <code>SELECT *
+ FROM PERSON t0, COMPANY t1
+ WHERE t0.ID = 10 AND t0.COMPANY_ID = t1.ID AND t1.NAME = 'OpenJPA'\
+ </code>
+ and
+ <code>INSERT INTO PERSON VALUES('Patrick', 'Linskey', 'OpenJPA', \
+ '202 595 2064 x1111')</code>
+ becomes
+ <code>INSERT INTO PERSON VALUES('Patrick', 'Linskey', 'OpenJPA', '202
+ 595 2064 x1111')</code>
+ etc.
+ *
+ * @author Patrick Linskey
*/
public class SQLFormatter {
- private static final String[] selectSeparators = new String[] {
- "FROM ", "WHERE ", "ORDER BY ", // ### is this order correct?
- "GROUP BY ", "HAVING ",
- };
- private static final String[] insertSeparators = new String[] { "VALUES ", };
- private static final String[] updateSeparators = new String[] {
- "SET ", "WHERE ",
- };
- private static final String[] deleteSeparators = new String[] { "WHERE ", };
- private static final String[] createTableSeparators = new String[] { "( ", };
- private static final String[] createIndexSeparators = new String[] {
- "ON ", "( ",
- };
private boolean multiLine = false;
private boolean doubleSpace = true;
private String newline = System.getProperty("line.separator");
@@ -65,6 +46,25 @@
private String wrapIndent = " ";
private String clauseIndent = " ";
+ private static final String[] selectSeparators = new String[] {
+ "FROM ", "WHERE ", "ORDER BY ", // ### is this order correct?
+ "GROUP BY ", "HAVING ", };
+
+ private static final String[] insertSeparators = new String[] {
+ "VALUES ", };
+
+ private static final String[] updateSeparators = new String[] {
+ "SET ", "WHERE ", };
+
+ private static final String[] deleteSeparators = new String[] {
+ "WHERE ", };
+
+ private static final String[] createTableSeparators = new String[] {
+ "( ", };
+
+ private static final String[] createIndexSeparators = new String[] {
+ "ON ", "( ", };
+
public void setNewline(String val) {
newline = val;
}
@@ -98,28 +98,28 @@
}
/**
- * If true, then try to parse multi-line SQL statements.
+ * If true, then try to parse multi-line SQL statements.
*/
public void setMultiLine(boolean multiLine) {
this.multiLine = multiLine;
}
/**
- * If true, then try to parse multi-line SQL statements.
+ * If true, then try to parse multi-line SQL statements.
*/
public boolean getMultiLine() {
return this.multiLine;
}
/**
- * If true, then output two lines after multi-line statements.
+ * If true, then output two lines after multi-line statements.
*/
public void setDoubleSpace(boolean doubleSpace) {
this.doubleSpace = doubleSpace;
}
/**
- * If true, then output two lines after multi-line statements.
+ * If true, then output two lines after multi-line statements.
*/
public boolean getDoubleSpace() {
return this.doubleSpace;
@@ -136,20 +136,17 @@
String line = null;
int index = Math.max(sql.toString().indexOf(";\n"),
- sql.toString().indexOf(";\r"));
-
- if (index == -1) {
+ sql.toString().indexOf(";\r"));
+ if (index == -1)
line = sql.toString();
- } else {
+ else
line = sql.substring(0, index + 2);
- }
// remove the current line from the sql buffer
sql.delete(0, line.length());
buf.append(prettyPrintLine(line));
-
- for (int i = 0; i < (1 + (getDoubleSpace() ? 1 : 0)); i++)
+ for (int i = 0; i < 1 + (getDoubleSpace() ? 1 : 0); i++)
buf.append(System.getProperty("line.separator"));
}
@@ -162,35 +159,31 @@
String lowerCaseSql = sql.toLowerCase();
String[] separators;
-
- if (lowerCaseSql.startsWith("select")) {
+ if (lowerCaseSql.startsWith("select"))
separators = selectSeparators;
- } else if (lowerCaseSql.startsWith("insert")) {
+ else if (lowerCaseSql.startsWith("insert"))
separators = insertSeparators;
- } else if (lowerCaseSql.startsWith("update")) {
+ else if (lowerCaseSql.startsWith("update"))
separators = updateSeparators;
- } else if (lowerCaseSql.startsWith("delete")) {
+ else if (lowerCaseSql.startsWith("delete"))
separators = deleteSeparators;
- } else if (lowerCaseSql.startsWith("create table")) {
+ else if (lowerCaseSql.startsWith("create table"))
separators = createTableSeparators;
- } else if (lowerCaseSql.startsWith("create index")) {
+ else if (lowerCaseSql.startsWith("create index"))
separators = createIndexSeparators;
- } else {
+ else
separators = new String[0];
- }
int start = 0;
int end = -1;
StringBuffer clause;
List clauses = new ArrayList();
clauses.add(new StringBuffer());
-
for (int i = 0; i < separators.length; i++) {
- end = lowerCaseSql.indexOf(" " + separators[i].toLowerCase(), start);
-
- if (end == -1) {
+ end = lowerCaseSql.indexOf(" " + separators[i].toLowerCase(),
+ start);
+ if (end == -1)
break;
- }
clause = (StringBuffer) clauses.get(clauses.size() - 1);
clause.append(sql.substring(start, end));
@@ -207,13 +200,10 @@
clause.append(sql.substring(start));
StringBuffer pp = new StringBuffer(sql.length());
-
- for (Iterator iter = clauses.iterator(); iter.hasNext();) {
+ for (Iterator iter = clauses.iterator(); iter.hasNext(); ) {
pp.append(wrapLine(((StringBuffer) iter.next()).toString()));
-
- if (iter.hasNext()) {
+ if (iter.hasNext())
pp.append(newline);
- }
}
return pp.toString();
@@ -223,16 +213,14 @@
StringBuffer lines = new StringBuffer(line.length());
// ensure that any leading whitespace is preserved.
- for (int i = 0;
- (i < line.length()) &&
- ((line.charAt(i) == ' ') || (line.charAt(i) == '\t')); i++) {
+ for (int i = 0; i < line.length() &&
+ (line.charAt(i) == ' ' || line.charAt(i) == '\t'); i++) {
lines.append(line.charAt(i));
}
StringTokenizer tok = new StringTokenizer(line);
int length = 0;
String elem;
-
while (tok.hasMoreTokens()) {
elem = tok.nextToken();
length += elem.length();
@@ -245,7 +233,6 @@
lines.append(elem);
lines.append(' ');
length = wrapIndent.length() + elem.length() + 1;
-
continue;
}
@@ -254,14 +241,10 @@
// newline and move on.
if (elem.length() >= lineLength) {
lines.append(elem);
-
- if (tok.hasMoreTokens()) {
+ if (tok.hasMoreTokens())
lines.append(newline);
- }
-
lines.append(wrapIndent);
length = wrapIndent.length();
-
continue;
}
@@ -273,9 +256,8 @@
return lines.toString();
}
- public static void main(String[] args) {
+ public static void main(String [] args) {
SQLFormatter formatter = new SQLFormatter();
-
for (int i = 0; i < args.length; i++) {
System.out.println(formatter.prettyPrint(args[i]));
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/AbstractLog.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/AbstractLog.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/AbstractLog.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/AbstractLog.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,25 +14,24 @@
import java.io.*;
-
/**
- * A simple implementation of the {@link Log} interface. Writes
- * output to stdout.
- *
- * @author Patrick Linskey
+ * A simple implementation of the {@link Log} interface. Writes
+ * output to stdout.
+ *
+ * @author Patrick Linskey
*/
public abstract class AbstractLog implements Log {
/**
- * Check to see if the specified logging level is enabled.
+ * Check to see if the specified logging level is enabled.
*/
protected abstract boolean isEnabled(short level);
/**
- * Send the specified log message to the handler.
- *
- * @param level the level of the log message
- * @param message the message to send
- * @param t the Throwable, or null if this is not an error
+ * Send the specified log message to the handler.
+ *
+ * @param level the level of the log message
+ * @param message the message to send
+ * @param t the Throwable, or null if this is not an error
*/
protected abstract void log(short level, String message, Throwable t);
@@ -68,9 +64,8 @@
}
public void trace(Object message, Throwable t) {
- if (isTraceEnabled()) {
+ if (isTraceEnabled())
log(TRACE, toString(message), throwableParam(message, t));
- }
}
public void debug(Object message) {
@@ -78,9 +73,8 @@
}
public void debug(Object message, Throwable t) {
- if (isDebugEnabled()) {
+ if (isDebugEnabled())
log(DEBUG, toString(message), throwableParam(message, t));
- }
}
public void info(Object message) {
@@ -88,9 +82,8 @@
}
public void info(Object message, Throwable t) {
- if (isInfoEnabled()) {
+ if (isInfoEnabled())
log(INFO, toString(message), throwableParam(message, t));
- }
}
public void warn(Object message) {
@@ -98,9 +91,8 @@
}
public void warn(Object message, Throwable t) {
- if (isWarnEnabled()) {
+ if (isWarnEnabled())
log(WARN, toString(message), throwableParam(message, t));
- }
}
public void error(Object message) {
@@ -108,9 +100,8 @@
}
public void error(Object message, Throwable t) {
- if (isErrorEnabled()) {
+ if (isErrorEnabled())
log(ERROR, toString(message), throwableParam(message, t));
- }
}
public void fatal(Object message) {
@@ -118,42 +109,37 @@
}
public void fatal(Object message, Throwable t) {
- if (isFatalEnabled()) {
+ if (isFatalEnabled())
log(FATAL, toString(message), throwableParam(message, t));
- }
}
/**
- * Utility method to obtain a stack trace as a String.
+ * Utility method to obtain a stack trace as a String.
*/
protected static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
t.printStackTrace(pw);
pw.close();
-
return sw.toString();
}
/**
- * If either given instance is a throwable, return it.
+ * If either given instance is a throwable, return it.
*/
private static Throwable throwableParam(Object message, Throwable t) {
- if (t != null) {
+ if (t != null)
return t;
- }
-
- if (message instanceof Throwable) {
- return (Throwable) message;
- }
+ if (message instanceof Throwable)
+ return(Throwable)message;
return null;
}
/**
- * Efficiently turn the given object into a string.
- */
+ * Efficiently turn the given object into a string.
+ */
private static String toString(Object o) {
- return (o == null) ? "null" : o.toString();
+ return(o == null) ? "null" : o.toString();
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/CommonsLogFactory.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/CommonsLogFactory.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/CommonsLogFactory.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/CommonsLogFactory.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -17,12 +14,11 @@
import java.util.*;
-
/**
- * {@link LogFactory} implementation that delegates to the commons logging
- * framework.
- *
- * @author Patrick Linskey
+ * {@link LogFactory} implementation that delegates to the commons logging
+ * framework.
+ *
+ * @author Patrick Linskey
*/
public class CommonsLogFactory extends LogFactoryAdapter {
private org.apache.commons.logging.LogFactory _factory;
@@ -36,8 +32,8 @@
}
/**
- * Adapts a commons logging log to the {@link org.apache.openjpa.lib.log.Log}
- * interface.
+ * Adapts a commons logging log to the {@link org.apache.openjpa.lib.log.Log}
+ * interface.
*/
public static class LogAdapter implements org.apache.openjpa.lib.log.Log {
private org.apache.commons.logging.Log _log;
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
@@ -15,12 +12,11 @@
*/
package org.apache.openjpa.lib.log;
-
/**
- * Logging interface that is independent of other logging frameworks.
- *
- * @author Patrick Linskey
- * @author Abe White
+ * Logging interface that is independent of other logging frameworks.
+ *
+ * @author Patrick Linskey
+ * @author Abe White
*/
public interface Log {
public static final short TRACE = 1;
@@ -31,116 +27,116 @@
public static final short FATAL = 6;
/**
- * Returns if the {@link #TRACE} log level is enabled.
+ * Returns if the {@link #TRACE} log level is enabled.
*/
public boolean isTraceEnabled();
/**
- * Returns if the {@link #DEBUG} log level is enabled.
+ * Returns if the {@link #DEBUG} log level is enabled.
*/
public boolean isDebugEnabled();
/**
- * Returns if the {@link #INFO} log level is enabled.
+ * Returns if the {@link #INFO} log level is enabled.
*/
public boolean isInfoEnabled();
/**
- * Returns if the {@link #WARN} log level is enabled.
+ * Returns if the {@link #WARN} log level is enabled.
*/
public boolean isWarnEnabled();
/**
- * Returns if the {@link #ERROR} log level is enabled.
+ * Returns if the {@link #ERROR} log level is enabled.
*/
public boolean isErrorEnabled();
/**
- * Returns if the {@link #FATAL} log level is enabled.
+ * Returns if the {@link #FATAL} log level is enabled.
*/
public boolean isFatalEnabled();
/**
- * Write out a log message at the {@link #TRACE}
- * level with the stringification of <code>o</code> as the body
- * of the message.
+ * Write out a log message at the {@link #TRACE}
+ * level with the stringification of <code>o</code> as the body
+ * of the message.
*/
public void trace(Object o);
/**
- * Write out a log message at the {@link #TRACE}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #TRACE}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void trace(Object o, Throwable t);
/**
- * Write out a log message at the {@link #DEBUG}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #DEBUG}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void debug(Object o);
/**
- * Write out a log message at the {@link #DEBUG}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #DEBUG}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void debug(Object o, Throwable t);
/**
- * Write out a log message at the {@link #INFO}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #INFO}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void info(Object o);
/**
- * Write out a log message at the {@link #INFO}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #INFO}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void info(Object o, Throwable t);
/**
- * Write out a log message at the {@link #WARN}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #WARN}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void warn(Object o);
/**
- * Write out a log message at the {@link #WARN}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #WARN}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void warn(Object o, Throwable t);
/**
- * Write out a log message at the {@link #ERROR}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #ERROR}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void error(Object o);
/**
- * Write out a log message at the {@link #ERROR}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #ERROR}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void error(Object o, Throwable t);
/**
- * Write out a log message at the {@link #FATAL}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #FATAL}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void fatal(Object o);
/**
- * Write out a log message at the {@link #FATAL}
- * level with the stringification of <code>o</code> as the body
- * of the message, also outputting <code>t</code> to the log.
+ * Write out a log message at the {@link #FATAL}
+ * level with the stringification of <code>o</code> as the body
+ * of the message, also outputting <code>t</code> to the log.
*/
public void fatal(Object o, Throwable t);
}