提交 b299be02 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 9d0af5f0
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</delete> </delete>
</target> </target>
<target name="compile" depends="switchSourceAuto, resources, downloadServletJar, downloadLuceneJar"> <target name="compile" depends="switchSourceAuto, resources, download">
<javac destdir="bin" debug="true" debuglevel="lines,source" > <javac destdir="bin" debug="true" debuglevel="lines,source" >
<classpath location="ext/servlet-api-2.4.jar" /> <classpath location="ext/servlet-api-2.4.jar" />
<classpath location="ext/lucene-core-2.2.0.jar" /> <classpath location="ext/lucene-core-2.2.0.jar" />
...@@ -60,20 +60,24 @@ ...@@ -60,20 +60,24 @@
<javac srcdir="bin" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/**"/> <javac srcdir="bin" destdir="bin" debug="true" debuglevel="lines,source" includes="org/h2/**"/>
</target> </target>
<target name="downloadServletJar" depends="init" unless="servlet.jar.present"> <target name="download" depends="init" unless="ext.present">
<get dest="ext/servlet-api-2.4.jar" <get dest="ext/servlet-api-2.4.jar"
src="http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar" /> src="http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar" />
</target>
<target name="downloadLuceneJar" depends="init" unless="lucene.jar.present">
<get dest="ext/lucene-core-2.2.0.jar" <get dest="ext/lucene-core-2.2.0.jar"
src="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar" /> src="http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar" />
<get dest="ext/slf4j-api-1.5.0.jar"
src="http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar" />
</target> </target>
<target name="init"> <target name="init">
<mkdir dir="ext"/> <mkdir dir="ext"/>
<available file="ext/servlet-api-2.4.jar" property="servlet.jar.present"/> <condition property="ext.present">
<available file="ext/lucene-core-2.2.0.jar" property="lucene.jar.present"/> <and>
<available file="ext/servlet-api-2.4.jar"/>
<available file="ext/lucene-core-2.2.0.jar"/>
<available file="ext/slf4j-api-1.5.0.jar"/>
</and>
</condition>
</target> </target>
<target name="jar" depends="compile, manifest"> <target name="jar" depends="compile, manifest">
......
...@@ -51,6 +51,8 @@ Features ...@@ -51,6 +51,8 @@ Features
Compatibility</a><br /> Compatibility</a><br />
<a href="#trace_options"> <a href="#trace_options">
Using the Trace Options</a><br /> Using the Trace Options</a><br />
<a href="#other_logging">
Using Other Logging APIs</a><br />
<a href="#read_only"> <a href="#read_only">
Read Only Databases</a><br /> Read Only Databases</a><br />
<a href="#database_in_zip"> <a href="#database_in_zip">
...@@ -1026,6 +1028,34 @@ However, if the start file is read only, the database engine cannot delete the f ...@@ -1026,6 +1028,34 @@ However, if the start file is read only, the database engine cannot delete the f
will always enable the trace mode when connecting. will always enable the trace mode when connecting.
</p> </p>
<br /><a name="other_logging"></a>
<h2>Using Other Logging APIs</h2>
<p>
By default, this database uses its own native 'trace' facility. This facility is called 'trace' and not
'log' within this database to avoid confusion with the transaction log. Trace messages can be
written to both file and System.out. In most cases, this is sufficient, however sometimes
it is better to use the same facility as the application, for example Log4j. To do that, this
database support SLF4J.
</p>
<p>
<a href="http://www.slf4j.org">SLF4J</a> is a simple facade for various logging APIs
and allows to plug in the desired implementation at deployment time.
SLF4J supports implementations such as Logback, Log4j, Jakarta Commons Logging (JCL),
JDK 1.4 logging, x4juli, and Simple Log.
</p>
<p>
To enable SLF4J, set the file trace level to 4 in the database URL:
</p>
<pre>
jdbc:h2:~/test;TRACE_LEVEL_FILE=4
</pre>
<p>
Changing the log mechanism is not possible after the database is open, that means
executing the SQL statement SET TRACE_LEVEL_FILE 4 when the database is already open
will not have the desired effect. To use SLF4J, all required jar files need to be in the classpath.
If it does not work, check in the file &lt;database&gt;.trace.db for error messages.
</p>
<br /><a name="read_only"></a> <br /><a name="read_only"></a>
<h2>Read Only Databases</h2> <h2>Read Only Databases</h2>
<p> <p>
......
...@@ -53,7 +53,6 @@ Roadmap ...@@ -53,7 +53,6 @@ Roadmap
<li>Automatic mode: jdbc:h2:auto: (embedded mode if possible, if not use server mode). Keep the server running until all have disconnected. <li>Automatic mode: jdbc:h2:auto: (embedded mode if possible, if not use server mode). Keep the server running until all have disconnected.
</li><li>Support OSGi: http://oscar-osgi.sourceforge.net, http://incubator.apache.org/felix/index.html </li><li>Support OSGi: http://oscar-osgi.sourceforge.net, http://incubator.apache.org/felix/index.html
</li><li>Better space re-use in the files after deleting data: shrink the data file without closing the database (if the end of the file is empty) </li><li>Better space re-use in the files after deleting data: shrink the data file without closing the database (if the end of the file is empty)
</li><li>Pluggable tracing system
</li><li>Full outer joins </li><li>Full outer joins
</li><li>Procedural language / script language (Javascript) </li><li>Procedural language / script language (Javascript)
</li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file) </li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -177,7 +177,7 @@ public abstract class Command implements CommandInterface { ...@@ -177,7 +177,7 @@ public abstract class Command implements CommandInterface {
session.unlockReadLocks(); session.unlockReadLocks();
} }
} }
if (trace.info()) { if (trace.isInfoEnabled()) {
long time = System.currentTimeMillis() - startTime; long time = System.currentTimeMillis() - startTime;
if (time > Constants.LONG_QUERY_LIMIT_MS) { if (time > Constants.LONG_QUERY_LIMIT_MS) {
trace.info("long query: " + time); trace.info("long query: " + time);
......
...@@ -278,7 +278,7 @@ public abstract class Prepared { ...@@ -278,7 +278,7 @@ public abstract class Prepared {
} }
void trace(long startTime, int count) throws SQLException { void trace(long startTime, int count) throws SQLException {
if (session.getTrace().info()) { if (session.getTrace().isInfoEnabled()) {
long time = System.currentTimeMillis() - startTime; long time = System.currentTimeMillis() - startTime;
String params; String params;
if (parameters.size() > 0) { if (parameters.size() > 0) {
......
...@@ -371,7 +371,7 @@ public class SessionRemote implements SessionInterface, DataHandler { ...@@ -371,7 +371,7 @@ public class SessionRemote implements SessionInterface, DataHandler {
* @param id the id of the operation * @param id the id of the operation
*/ */
public void traceOperation(String operation, int id) { public void traceOperation(String operation, int id) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debug(operation + " " + id); trace.debug(operation + " " + id);
} }
} }
......
...@@ -88,7 +88,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -88,7 +88,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public Statement createStatement() throws SQLException { public Statement createStatement() throws SQLException {
try { try {
int id = getNextId(TraceObject.STATEMENT); int id = getNextId(TraceObject.STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement()"); debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement()");
} }
checkClosed(); checkClosed();
...@@ -109,7 +109,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -109,7 +109,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
try { try {
int id = getNextId(TraceObject.STATEMENT); int id = getNextId(TraceObject.STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement(" + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement(" + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkClosed(); checkClosed();
...@@ -132,7 +132,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -132,7 +132,7 @@ public class JdbcConnection extends TraceObject implements Connection {
throws SQLException { throws SQLException {
try { try {
int id = getNextId(TraceObject.STATEMENT); int id = getNextId(TraceObject.STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, debugCodeAssign("Statement", TraceObject.STATEMENT, id,
"createStatement(" + resultSetType + ", " + resultSetConcurrency + ", " + resultSetHoldability + ")"); "createStatement(" + resultSetType + ", " + resultSetConcurrency + ", " + resultSetHoldability + ")");
} }
...@@ -155,7 +155,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -155,7 +155,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public PreparedStatement prepareStatement(String sql) throws SQLException { public PreparedStatement prepareStatement(String sql) throws SQLException {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ")"); debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ")");
} }
checkClosed(); checkClosed();
...@@ -169,7 +169,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -169,7 +169,7 @@ public class JdbcConnection extends TraceObject implements Connection {
PreparedStatement prepareAutoCloseStatement(String sql) throws SQLException { PreparedStatement prepareAutoCloseStatement(String sql) throws SQLException {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ")"); debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ")");
} }
checkClosed(); checkClosed();
...@@ -190,7 +190,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -190,7 +190,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public DatabaseMetaData getMetaData() throws SQLException { public DatabaseMetaData getMetaData() throws SQLException {
try { try {
int id = getNextId(TraceObject.DATABASE_META_DATA); int id = getNextId(TraceObject.DATABASE_META_DATA);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("DatabaseMetaData", TraceObject.DATABASE_META_DATA, id, "getMetaData()"); debugCodeAssign("DatabaseMetaData", TraceObject.DATABASE_META_DATA, id, "getMetaData()");
} }
checkClosed(); checkClosed();
...@@ -290,7 +290,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -290,7 +290,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
public synchronized void setAutoCommit(boolean autoCommit) throws SQLException { public synchronized void setAutoCommit(boolean autoCommit) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("setAutoCommit(" + autoCommit + ");"); debugCode("setAutoCommit(" + autoCommit + ");");
} }
checkClosed(); checkClosed();
...@@ -408,7 +408,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -408,7 +408,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
public void setReadOnly(boolean readOnly) throws SQLException { public void setReadOnly(boolean readOnly) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("setReadOnly(" + readOnly + ");"); debugCode("setReadOnly(" + readOnly + ");");
} }
checkClosed(); checkClosed();
...@@ -515,7 +515,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -515,7 +515,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkClosed(); checkClosed();
...@@ -717,7 +717,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -717,7 +717,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public CallableStatement prepareCall(String sql) throws SQLException { public CallableStatement prepareCall(String sql) throws SQLException {
try { try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT); int id = getNextId(TraceObject.CALLABLE_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql) + ")"); debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql) + ")");
} }
checkClosed(); checkClosed();
...@@ -740,7 +740,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -740,7 +740,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
try { try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT); int id = getNextId(TraceObject.CALLABLE_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")"); debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")");
} }
checkClosed(); checkClosed();
...@@ -765,7 +765,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -765,7 +765,7 @@ public class JdbcConnection extends TraceObject implements Connection {
int resultSetConcurrency, int resultSetHoldability) throws SQLException { int resultSetConcurrency, int resultSetHoldability) throws SQLException {
try { try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT); int id = getNextId(TraceObject.CALLABLE_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id,
"prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", " "prepareCall(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", "
+ resultSetHoldability + ")"); + resultSetHoldability + ")");
...@@ -789,7 +789,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -789,7 +789,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public Savepoint setSavepoint() throws SQLException { public Savepoint setSavepoint() throws SQLException {
try { try {
int id = getNextId(TraceObject.SAVEPOINT); int id = getNextId(TraceObject.SAVEPOINT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint()"); debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint()");
} }
checkClosed(); checkClosed();
...@@ -813,7 +813,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -813,7 +813,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public Savepoint setSavepoint(String name) throws SQLException { public Savepoint setSavepoint(String name) throws SQLException {
try { try {
int id = getNextId(TraceObject.SAVEPOINT); int id = getNextId(TraceObject.SAVEPOINT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint(" + quote(name) + ")"); debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint(" + quote(name) + ")");
} }
checkClosed(); checkClosed();
...@@ -876,7 +876,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -876,7 +876,7 @@ public class JdbcConnection extends TraceObject implements Connection {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
try { try {
int id = getNextId(TraceObject.PREPARED_STATEMENT); int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id,
"prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", " "prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", "
+ resultSetHoldability + ")"); + resultSetHoldability + ")");
...@@ -901,7 +901,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -901,7 +901,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("prepareStatement(" + quote(sql) + ", " + autoGeneratedKeys + ");"); debugCode("prepareStatement(" + quote(sql) + ", " + autoGeneratedKeys + ");");
} }
return prepareStatement(sql); return prepareStatement(sql);
...@@ -920,7 +920,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -920,7 +920,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("prepareStatement(" + quote(sql) + ", " + quoteIntArray(columnIndexes) + ");"); debugCode("prepareStatement(" + quote(sql) + ", " + quoteIntArray(columnIndexes) + ");");
} }
return prepareStatement(sql); return prepareStatement(sql);
...@@ -939,7 +939,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -939,7 +939,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("prepareStatement(" + quote(sql) + ", " + quoteArray(columnNames) + ");"); debugCode("prepareStatement(" + quote(sql) + ", " + quoteArray(columnNames) + ");");
} }
return prepareStatement(sql); return prepareStatement(sql);
...@@ -979,7 +979,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -979,7 +979,7 @@ public class JdbcConnection extends TraceObject implements Connection {
int id = getNextId(TraceObject.CONNECTION); int id = getNextId(TraceObject.CONNECTION);
setTrace(trace, TraceObject.CONNECTION, id); setTrace(trace, TraceObject.CONNECTION, id);
this.user = ci.getUserName(); this.user = ci.getUserName();
if (info()) { if (isInfoEnabled()) {
trace.infoCode("Connection " + getTraceObjectName() trace.infoCode("Connection " + getTraceObjectName()
+ " = DriverManager.getConnection(" + quote(ci.getOriginalURL()) + " = DriverManager.getConnection(" + quote(ci.getOriginalURL())
+ ", " + quote(user) + ", \"\")"); + ", " + quote(user) + ", \"\")");
......
...@@ -115,7 +115,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -115,7 +115,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getTables(" + quote(catalog) + ", " + quote(schemaPattern) + ", " + quote(tableNamePattern) debugCode("getTables(" + quote(catalog) + ", " + quote(schemaPattern) + ", " + quote(tableNamePattern)
+ ", " + quoteArray(types) + ");"); + ", " + quoteArray(types) + ");");
} }
...@@ -199,7 +199,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -199,7 +199,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String tableNamePattern, String columnNamePattern) String tableNamePattern, String columnNamePattern)
throws SQLException { throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getColumns(" + quote(catalog)+", " debugCode("getColumns(" + quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
+quote(tableNamePattern)+", " +quote(tableNamePattern)+", "
...@@ -277,7 +277,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -277,7 +277,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getIndexInfo(String catalog, String schema, String tableName, boolean unique, boolean approximate) public ResultSet getIndexInfo(String catalog, String schema, String tableName, boolean unique, boolean approximate)
throws SQLException { throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getIndexInfo(" + quote(catalog) + ", " + quote(schema) + ", " + quote(tableName) + ", " debugCode("getIndexInfo(" + quote(catalog) + ", " + quote(schema) + ", " + quote(tableName) + ", "
+ unique + ", " + approximate + ");"); + unique + ", " + approximate + ");");
} }
...@@ -339,7 +339,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -339,7 +339,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public ResultSet getPrimaryKeys(String catalog, String schema, String tableName) throws SQLException { public ResultSet getPrimaryKeys(String catalog, String schema, String tableName) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getPrimaryKeys(" debugCode("getPrimaryKeys("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -507,7 +507,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -507,7 +507,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getProcedures(String catalog, String schemaPattern, public ResultSet getProcedures(String catalog, String schemaPattern,
String procedureNamePattern) throws SQLException { String procedureNamePattern) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getProcedures(" debugCode("getProcedures("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -562,7 +562,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -562,7 +562,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String procedureNamePattern, String columnNamePattern) String procedureNamePattern, String columnNamePattern)
throws SQLException { throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getProcedureColumns(" debugCode("getProcedureColumns("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -708,7 +708,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -708,7 +708,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getColumnPrivileges(String catalog, String schema, public ResultSet getColumnPrivileges(String catalog, String schema,
String table, String columnNamePattern) throws SQLException { String table, String columnNamePattern) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getColumnPrivileges(" debugCode("getColumnPrivileges("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -767,7 +767,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -767,7 +767,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getTablePrivileges(" debugCode("getTablePrivileges("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -822,7 +822,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -822,7 +822,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getBestRowIdentifier(String catalog, String schema, public ResultSet getBestRowIdentifier(String catalog, String schema,
String tableName, int scope, boolean nullable) throws SQLException { String tableName, int scope, boolean nullable) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getBestRowIdentifier(" debugCode("getBestRowIdentifier("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -882,7 +882,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -882,7 +882,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getVersionColumns(String catalog, String schema, public ResultSet getVersionColumns(String catalog, String schema,
String tableName) throws SQLException { String tableName) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getVersionColumns(" debugCode("getVersionColumns("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -939,7 +939,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -939,7 +939,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
*/ */
public ResultSet getImportedKeys(String catalog, String schema, String tableName) throws SQLException { public ResultSet getImportedKeys(String catalog, String schema, String tableName) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getImportedKeys(" debugCode("getImportedKeys("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -1009,7 +1009,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1009,7 +1009,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getExportedKeys(String catalog, String schema, String tableName) public ResultSet getExportedKeys(String catalog, String schema, String tableName)
throws SQLException { throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getExportedKeys(" debugCode("getExportedKeys("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schema)+", " +quote(schema)+", "
...@@ -1086,7 +1086,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1086,7 +1086,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String primarySchema, String primaryTable, String foreignCatalog, String primarySchema, String primaryTable, String foreignCatalog,
String foreignSchema, String foreignTable) throws SQLException { String foreignSchema, String foreignTable) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getCrossReference(" debugCode("getCrossReference("
+quote(primaryCatalog)+", " +quote(primaryCatalog)+", "
+quote(primarySchema)+", " +quote(primarySchema)+", "
...@@ -1155,7 +1155,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1155,7 +1155,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getUDTs(String catalog, String schemaPattern, public ResultSet getUDTs(String catalog, String schemaPattern,
String typeNamePattern, int[] types) throws SQLException { String typeNamePattern, int[] types) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getUDTs(" debugCode("getUDTs("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -1429,7 +1429,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -1429,7 +1429,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* @return true * @return true
*/ */
public boolean supportsConvert(int fromType, int toType) { public boolean supportsConvert(int fromType, int toType) {
if (debug()) { if (isDebugEnabled()) {
debugCode("supportsConvert("+fromType+", "+fromType+");"); debugCode("supportsConvert("+fromType+", "+fromType+");");
} }
return true; return true;
...@@ -2030,7 +2030,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2030,7 +2030,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* @return true if the type is not ResultSet.TYPE_SCROLL_SENSITIVE * @return true if the type is not ResultSet.TYPE_SCROLL_SENSITIVE
*/ */
public boolean supportsResultSetConcurrency(int type, int concurrency) { public boolean supportsResultSetConcurrency(int type, int concurrency) {
if (debug()) { if (isDebugEnabled()) {
debugCode("supportsResultSetConcurrency("+type+", "+concurrency+");"); debugCode("supportsResultSetConcurrency("+type+", "+concurrency+");");
} }
return type != ResultSet.TYPE_SCROLL_SENSITIVE; return type != ResultSet.TYPE_SCROLL_SENSITIVE;
...@@ -2448,7 +2448,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2448,7 +2448,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getSuperTypes(String catalog, String schemaPattern, public ResultSet getSuperTypes(String catalog, String schemaPattern,
String typeNamePattern) throws SQLException { String typeNamePattern) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getSuperTypes(" debugCode("getSuperTypes("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -2476,7 +2476,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2476,7 +2476,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
public ResultSet getSuperTables(String catalog, String schemaPattern, public ResultSet getSuperTables(String catalog, String schemaPattern,
String tableNamePattern) throws SQLException { String tableNamePattern) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getSuperTables(" debugCode("getSuperTables("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
...@@ -2503,7 +2503,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2503,7 +2503,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
String typeNamePattern, String attributeNamePattern) String typeNamePattern, String attributeNamePattern)
throws SQLException { throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("getAttributes(" debugCode("getAttributes("
+quote(catalog)+", " +quote(catalog)+", "
+quote(schemaPattern)+", " +quote(schemaPattern)+", "
......
...@@ -50,7 +50,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -50,7 +50,7 @@ public class JdbcStatement extends TraceObject implements Statement {
public ResultSet executeQuery(String sql) throws SQLException { public ResultSet executeQuery(String sql) throws SQLException {
try { try {
int id = getNextId(TraceObject.RESULT_SET); int id = getNextId(TraceObject.RESULT_SET);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "executeQuery(" + quote(sql) + ")"); debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "executeQuery(" + quote(sql) + ")");
} }
checkClosed(); checkClosed();
...@@ -132,7 +132,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -132,7 +132,7 @@ public class JdbcStatement extends TraceObject implements Statement {
public boolean execute(String sql) throws SQLException { public boolean execute(String sql) throws SQLException {
try { try {
int id = getNextId(TraceObject.RESULT_SET); int id = getNextId(TraceObject.RESULT_SET);
if (debug()) { if (isDebugEnabled()) {
debugCodeCall("execute", sql); debugCodeCall("execute", sql);
} }
checkClosed(); checkClosed();
...@@ -482,7 +482,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -482,7 +482,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public void setEscapeProcessing(boolean enable) throws SQLException { public void setEscapeProcessing(boolean enable) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("setEscapeProcessing("+enable+");"); debugCode("setEscapeProcessing("+enable+");");
} }
checkClosed(); checkClosed();
...@@ -637,7 +637,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -637,7 +637,7 @@ public class JdbcStatement extends TraceObject implements Statement {
public ResultSet getGeneratedKeys() throws SQLException { public ResultSet getGeneratedKeys() throws SQLException {
try { try {
int id = getNextId(TraceObject.RESULT_SET); int id = getNextId(TraceObject.RESULT_SET);
if (debug()) { if (isDebugEnabled()) {
debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "getGeneratedKeys()"); debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "getGeneratedKeys()");
} }
checkClosed(); checkClosed();
...@@ -674,7 +674,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -674,7 +674,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("executeUpdate("+quote(sql)+", "+autoGeneratedKeys+");"); debugCode("executeUpdate("+quote(sql)+", "+autoGeneratedKeys+");");
} }
return executeUpdate(sql); return executeUpdate(sql);
...@@ -696,7 +696,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -696,7 +696,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("executeUpdate("+quote(sql)+", "+quoteIntArray(columnIndexes)+");"); debugCode("executeUpdate("+quote(sql)+", "+quoteIntArray(columnIndexes)+");");
} }
return executeUpdate(sql); return executeUpdate(sql);
...@@ -718,7 +718,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -718,7 +718,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public int executeUpdate(String sql, String[] columnNames) throws SQLException { public int executeUpdate(String sql, String[] columnNames) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("executeUpdate("+quote(sql)+", "+quoteArray(columnNames)+");"); debugCode("executeUpdate("+quote(sql)+", "+quoteArray(columnNames)+");");
} }
return executeUpdate(sql); return executeUpdate(sql);
...@@ -740,7 +740,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -740,7 +740,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("execute("+quote(sql)+", "+autoGeneratedKeys+");"); debugCode("execute("+quote(sql)+", "+autoGeneratedKeys+");");
} }
return execute(sql); return execute(sql);
...@@ -762,7 +762,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -762,7 +762,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public boolean execute(String sql, int[] columnIndexes) throws SQLException { public boolean execute(String sql, int[] columnIndexes) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("execute("+quote(sql)+", "+quoteIntArray(columnIndexes)+");"); debugCode("execute("+quote(sql)+", "+quoteIntArray(columnIndexes)+");");
} }
return execute(sql); return execute(sql);
...@@ -784,7 +784,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -784,7 +784,7 @@ public class JdbcStatement extends TraceObject implements Statement {
*/ */
public boolean execute(String sql, String[] columnNames) throws SQLException { public boolean execute(String sql, String[] columnNames) throws SQLException {
try { try {
if (debug()) { if (isDebugEnabled()) {
debugCode("execute("+quote(sql)+", "+quoteArray(columnNames)+");"); debugCode("execute("+quote(sql)+", "+quoteArray(columnNames)+");");
} }
return execute(sql); return execute(sql);
...@@ -893,7 +893,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -893,7 +893,7 @@ public class JdbcStatement extends TraceObject implements Statement {
* @param poolable the requested value * @param poolable the requested value
*/ */
public void setPoolable(boolean poolable) throws SQLException { public void setPoolable(boolean poolable) throws SQLException {
if (debug()) { if (isDebugEnabled()) {
debugCode("setPoolable("+poolable+");"); debugCode("setPoolable("+poolable+");");
} }
} }
......
...@@ -164,14 +164,14 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref ...@@ -164,14 +164,14 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
* @return the connection * @return the connection
*/ */
public Connection getConnection(String user, String password) throws SQLException { public Connection getConnection(String user, String password) throws SQLException {
if (debug()) { if (isDebugEnabled()) {
debugCode("getConnection("+quote(user)+", "+quote(password)+");"); debugCode("getConnection("+quote(user)+", "+quote(password)+");");
} }
return getJdbcConnection(user, password); return getJdbcConnection(user, password);
} }
private JdbcConnection getJdbcConnection(String user, String password) throws SQLException { private JdbcConnection getJdbcConnection(String user, String password) throws SQLException {
if (debug()) { if (isDebugEnabled()) {
debugCode("getJdbcConnection("+quote(user)+", "+quote(password)+");"); debugCode("getJdbcConnection("+quote(user)+", "+quote(password)+");");
} }
Properties info = new Properties(); Properties info = new Properties();
...@@ -281,7 +281,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref ...@@ -281,7 +281,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public XAConnection getXAConnection(String user, String password) throws SQLException { public XAConnection getXAConnection(String user, String password) throws SQLException {
if (debug()) { if (isDebugEnabled()) {
debugCode("getXAConnection("+quote(user)+", "+quote(password)+");"); debugCode("getXAConnection("+quote(user)+", "+quote(password)+");");
} }
int id = getNextId(XA_DATA_SOURCE); int id = getNextId(XA_DATA_SOURCE);
...@@ -311,7 +311,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref ...@@ -311,7 +311,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public PooledConnection getPooledConnection(String user, String password) throws SQLException { public PooledConnection getPooledConnection(String user, String password) throws SQLException {
if (debug()) { if (isDebugEnabled()) {
debugCode("getPooledConnection("+quote(user)+", "+quote(password)+");"); debugCode("getPooledConnection("+quote(user)+", "+quote(password)+");");
} }
return getXAConnection(user, password); return getXAConnection(user, password);
......
...@@ -60,7 +60,7 @@ implements ObjectFactory ...@@ -60,7 +60,7 @@ implements ObjectFactory
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public synchronized Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { public synchronized Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debug("getObjectInstance obj=" + obj + " name=" + name + " nameCtx=" + nameCtx + " environment=" + environment); trace.debug("getObjectInstance obj=" + obj + " name=" + name + " nameCtx=" + nameCtx + " environment=" + environment);
} }
Reference ref = (Reference) obj; Reference ref = (Reference) obj;
......
...@@ -252,7 +252,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -252,7 +252,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public int prepare(Xid xid) throws XAException { public int prepare(Xid xid) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("prepare("+quoteXid(xid)+");"); debugCode("prepare("+quoteXid(xid)+");");
} }
checkOpen(); checkOpen();
...@@ -283,7 +283,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -283,7 +283,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public void forget(Xid xid) throws XAException { public void forget(Xid xid) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("forget("+quoteXid(xid)+");"); debugCode("forget("+quoteXid(xid)+");");
} }
} }
...@@ -296,7 +296,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -296,7 +296,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public void rollback(Xid xid) throws XAException { public void rollback(Xid xid) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("rollback("+quoteXid(xid)+");"); debugCode("rollback("+quoteXid(xid)+");");
} }
try { try {
...@@ -317,7 +317,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -317,7 +317,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public void end(Xid xid, int flags) throws XAException { public void end(Xid xid, int flags) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("end("+quoteXid(xid)+", "+quoteFlags(flags)+");"); debugCode("end("+quoteXid(xid)+", "+quoteFlags(flags)+");");
} }
// TODO transaction end: implement this method // TODO transaction end: implement this method
...@@ -339,7 +339,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -339,7 +339,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public void start(Xid xid, int flags) throws XAException { public void start(Xid xid, int flags) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("start("+quoteXid(xid)+", "+quoteFlags(flags)+");"); debugCode("start("+quoteXid(xid)+", "+quoteFlags(flags)+");");
} }
if (flags == TMRESUME) { if (flags == TMRESUME) {
...@@ -367,7 +367,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -367,7 +367,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public void commit(Xid xid, boolean onePhase) throws XAException { public void commit(Xid xid, boolean onePhase) throws XAException {
if (debug()) { if (isDebugEnabled()) {
debugCode("commit("+quoteXid(xid)+", "+onePhase+");"); debugCode("commit("+quoteXid(xid)+", "+onePhase+");");
} }
Statement stat = null; Statement stat = null;
...@@ -437,7 +437,7 @@ implements XAConnection, XAResource, JdbcConnectionListener ...@@ -437,7 +437,7 @@ implements XAConnection, XAResource, JdbcConnectionListener
} }
private XAException convertException(SQLException e) { private XAException convertException(SQLException e) {
if (debug()) { if (isDebugEnabled()) {
getTrace().debug("throw XAException("+e.getMessage()+");"); getTrace().debug("throw XAException("+e.getMessage()+");");
} }
return new XAException(e.getMessage()); return new XAException(e.getMessage());
......
...@@ -14,9 +14,7 @@ import org.h2.util.StringUtils; ...@@ -14,9 +14,7 @@ import org.h2.util.StringUtils;
*/ */
public class Trace { public class Trace {
// TODO trace: java code generation does not always work private TraceWriter traceWriter;
private TraceSystem traceSystem;
private String module; private String module;
private String lineSeparator; private String lineSeparator;
...@@ -38,44 +36,45 @@ public class Trace { ...@@ -38,44 +36,45 @@ public class Trace {
public static final String SESSION = "session"; public static final String SESSION = "session";
public static final String AGGREGATE = "aggregate"; public static final String AGGREGATE = "aggregate";
public Trace(TraceSystem traceSystem, String module) { Trace(TraceWriter traceWriter, String module) {
this.traceSystem = traceSystem; this.traceWriter = traceWriter;
this.module = module; this.module = module;
this.lineSeparator = SysProperties.LINE_SEPARATOR; this.lineSeparator = SysProperties.LINE_SEPARATOR;
} }
public boolean info() { public boolean isInfoEnabled() {
return traceSystem.isEnabled(TraceSystem.INFO); return traceWriter.isEnabled(TraceSystem.INFO);
} }
public boolean debug() { public boolean isDebugEnabled() {
return traceSystem.isEnabled(TraceSystem.DEBUG); return traceWriter.isEnabled(TraceSystem.DEBUG);
} }
public void error(String s) { public void error(String s) {
traceSystem.write(TraceSystem.ERROR, module, s, null); traceWriter.write(TraceSystem.ERROR, module, s, null);
} }
public void error(String s, Throwable t) { public void error(String s, Throwable t) {
traceSystem.write(TraceSystem.ERROR, module, s, t); traceWriter.write(TraceSystem.ERROR, module, s, t);
} }
public void info(String s) { public void info(String s) {
traceSystem.write(TraceSystem.INFO, module, s, null); traceWriter.write(TraceSystem.INFO, module, s, null);
} }
public void debugCode(String java) { public void debugCode(String java) {
traceSystem.write(TraceSystem.DEBUG, module, lineSeparator + "/**/" + java, null); traceWriter.write(TraceSystem.DEBUG, module, lineSeparator + "/**/" + java, null);
} }
public void infoCode(String java) { public void infoCode(String java) {
traceSystem.write(TraceSystem.INFO, module, lineSeparator + "/**/" + java, null); traceWriter.write(TraceSystem.INFO, module, lineSeparator + "/**/" + java, null);
} }
public void infoSQL(String sql, String params, int count, long time) { public void infoSQL(String sql, String params, int count, long time) {
StringBuffer buff = new StringBuffer(sql.length() + 20); StringBuffer buff = new StringBuffer(sql.length() + 20);
buff.append(lineSeparator); buff.append(lineSeparator);
buff.append("/*SQL "); buff.append("/*SQL");
boolean space = false;
if (params.length() > 0) { if (params.length() > 0) {
// This looks like a bug, but it is intentional: // This looks like a bug, but it is intentional:
// If there are no parameters, the SQL statement is // If there are no parameters, the SQL statement is
...@@ -83,31 +82,37 @@ public class Trace { ...@@ -83,31 +82,37 @@ public class Trace {
// are appended at the end of the line. Knowing the size // are appended at the end of the line. Knowing the size
// of the statement simplifies separating the SQL statement // of the statement simplifies separating the SQL statement
// from the parameters (no need to parse). // from the parameters (no need to parse).
buff.append("l:"); space = true;
buff.append(" l:");
buff.append(sql.length()); buff.append(sql.length());
} }
if (count > 0) { if (count > 0) {
space = true;
buff.append(" #:"); buff.append(" #:");
buff.append(count); buff.append(count);
} }
if (time > 0) { if (time > 0) {
space = true;
buff.append(" t:"); buff.append(" t:");
buff.append(time); buff.append(time);
} }
if (!space) {
buff.append(' ');
}
buff.append("*/"); buff.append("*/");
buff.append(StringUtils.javaEncode(sql)); buff.append(StringUtils.javaEncode(sql));
buff.append(params); buff.append(params);
buff.append(';'); buff.append(';');
sql = buff.toString(); sql = buff.toString();
traceSystem.write(TraceSystem.INFO, module, sql, null); traceWriter.write(TraceSystem.INFO, module, sql, null);
} }
public void debug(String s) { public void debug(String s) {
traceSystem.write(TraceSystem.DEBUG, module, s, null); traceWriter.write(TraceSystem.DEBUG, module, s, null);
} }
public void debug(String s, Throwable t) { public void debug(String s, Throwable t) {
traceSystem.write(TraceSystem.DEBUG, module, s, t); traceWriter.write(TraceSystem.DEBUG, module, s, t);
} }
} }
...@@ -60,12 +60,12 @@ public class TraceObject { ...@@ -60,12 +60,12 @@ public class TraceObject {
return ID[type]++; return ID[type]++;
} }
protected boolean debug() { protected boolean isDebugEnabled() {
return trace.debug(); return trace.isDebugEnabled();
} }
protected boolean info() { protected boolean isInfoEnabled() {
return trace.info(); return trace.isInfoEnabled();
} }
protected Trace getTrace() { protected Trace getTrace() {
...@@ -73,31 +73,31 @@ public class TraceObject { ...@@ -73,31 +73,31 @@ public class TraceObject {
} }
protected void debugCodeAssign(String className, int type, int id, String value) { protected void debugCodeAssign(String className, int type, int id, String value) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debugCode(className + " " + PREFIX[type] + id + " = " + getTraceObjectName() + "." + value + ";"); trace.debugCode(className + " " + PREFIX[type] + id + " = " + getTraceObjectName() + "." + value + ";");
} }
} }
protected void debugCodeCall(String text) { protected void debugCodeCall(String text) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debugCode(getTraceObjectName() + "." + text + "();"); trace.debugCode(getTraceObjectName() + "." + text + "();");
} }
} }
protected void debugCodeCall(String text, long param) { protected void debugCodeCall(String text, long param) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debugCode(getTraceObjectName() + "." + text + "(" + param + ");"); trace.debugCode(getTraceObjectName() + "." + text + "(" + param + ");");
} }
} }
protected void debugCodeCall(String text, String param) { protected void debugCodeCall(String text, String param) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debugCode(getTraceObjectName() + "." + text + "(" + quote(param) + ");"); trace.debugCode(getTraceObjectName() + "." + text + "(" + quote(param) + ");");
} }
} }
protected void debugCode(String text) { protected void debugCode(String text) {
if (trace.debug()) { if (trace.isDebugEnabled()) {
trace.debugCode(getTraceObjectName() + "." + text); trace.debugCode(getTraceObjectName() + "." + text);
} }
} }
......
...@@ -17,6 +17,7 @@ import java.util.Date; ...@@ -17,6 +17,7 @@ import java.util.Date;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.util.ClassUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.SmallLRUCache; import org.h2.util.SmallLRUCache;
...@@ -27,10 +28,9 @@ import org.h2.util.SmallLRUCache; ...@@ -27,10 +28,9 @@ import org.h2.util.SmallLRUCache;
* is possible to write after close was called, but that means for each write * is possible to write after close was called, but that means for each write
* the log file will be opened and closed again (which is slower). * the log file will be opened and closed again (which is slower).
*/ */
public class TraceSystem { public class TraceSystem implements TraceWriter {
public static final int OFF = 0, ERROR = 1, INFO = 2, DEBUG = 3; public static final int OFF = 0, ERROR = 1, INFO = 2, DEBUG = 3;
public static final int ADAPTER = 4;
// TODO log total and free memory from time to time
// max file size is currently 64 MB, // max file size is currently 64 MB,
// and then there could be a .old file of the same size // and then there could be a .old file of the same size
...@@ -52,6 +52,7 @@ public class TraceSystem { ...@@ -52,6 +52,7 @@ public class TraceSystem {
private boolean closed; private boolean closed;
private boolean manualEnabling = true; private boolean manualEnabling = true;
private boolean writingErrorLogged; private boolean writingErrorLogged;
private TraceWriter writer = this;
public static void traceThrowable(Throwable e) { public static void traceThrowable(Throwable e) {
PrintWriter writer = DriverManager.getLogWriter(); PrintWriter writer = DriverManager.getLogWriter();
...@@ -80,7 +81,7 @@ public class TraceSystem { ...@@ -80,7 +81,7 @@ public class TraceSystem {
public Trace getTrace(String module) { public Trace getTrace(String module) {
Trace t = (Trace) traces.get(module); Trace t = (Trace) traces.get(module);
if (t == null) { if (t == null) {
t = new Trace(this, module); t = new Trace(writer, module);
traces.put(module, t); traces.put(module, t);
} }
return t; return t;
...@@ -99,24 +100,33 @@ public class TraceSystem { ...@@ -99,24 +100,33 @@ public class TraceSystem {
this.maxFileSize = max; this.maxFileSize = max;
} }
public int getMaxFileSize() { public void setLevelSystemOut(int level) {
return maxFileSize; levelSystemOut = level;
}
public void setLevelSystemOut(int l) {
levelSystemOut = l;
}
public int getLevelFile() {
return levelFile;
}
public int getLevelSystemOut() {
return levelSystemOut;
} }
public void setLevelFile(int l) { public void setLevelFile(int level) {
levelFile = l; if (level == ADAPTER) {
String adapterClass = "org.h2.message.TraceWriterAdapter";
try {
writer = (TraceWriter) ClassUtils.loadSystemClass(adapterClass).newInstance();
} catch (Throwable e) {
e = Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[] { adapterClass }, e);
write(ERROR, Trace.DATABASE, adapterClass, e);
return;
}
String name = fileName;
if (name != null) {
if (name.endsWith(Constants.SUFFIX_TRACE_FILE)) {
name = name.substring(0, name.length() - Constants.SUFFIX_TRACE_FILE.length());
}
int idx = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\'));
if (idx >= 0) {
name = name.substring(idx + 1);
}
writer.setName(name);
}
}
levelFile = level;
} }
private String format(String module, String s) { private String format(String module, String s) {
...@@ -125,18 +135,18 @@ public class TraceSystem { ...@@ -125,18 +135,18 @@ public class TraceSystem {
} }
} }
void write(int l, String module, String s, Throwable t) { public void write(int level, String module, String s, Throwable t) {
if (l <= levelSystemOut) { if (level <= levelSystemOut) {
System.out.println(format(module, s)); System.out.println(format(module, s));
if (t != null && levelSystemOut == DEBUG) { if (t != null && levelSystemOut == DEBUG) {
t.printStackTrace(); t.printStackTrace();
} }
} }
if (fileName != null) { if (fileName != null) {
if (l > levelFile) { if (level > levelFile) {
enableIfRequired(); enableIfRequired();
} }
if (l <= levelFile) { if (level <= levelFile) {
writeFile(format(module, s), t); writeFile(format(module, s), t);
} }
} }
...@@ -195,7 +205,6 @@ public class TraceSystem { ...@@ -195,7 +205,6 @@ public class TraceSystem {
return; return;
} }
writingErrorLogged = true; writingErrorLogged = true;
// TODO translate trace messages
SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, new String[] { fileName, e.toString() }, SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, new String[] { fileName, e.toString() },
e); e);
// print this error only once // print this error only once
...@@ -258,4 +267,7 @@ public class TraceSystem { ...@@ -258,4 +267,7 @@ public class TraceSystem {
close(); close();
} }
public void setName(String name) {
}
} }
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.message;
/**
* The backend of the trace system must implement this interface. Two
* implementations are supported: the (default) native trace writer
* implementation that can write to a file and to system out, and an adapter
* that uses SLF4J (Simple Logging Facade for Java).
*/
interface TraceWriter {
/**
* Set the name of the database or trace object.
*/
void setName(String name);
/**
* Write a message.
*
* @param level the trace level
* @param module the name of the module
* @param s the message
* @param t the exception (may be null)
*/
void write(int level, String module, String s, Throwable t);
/**
* Check the given trace / log level is enabled.
*
* @param level the level
* @return true if the level is enabled
*/
boolean isEnabled(int level);
}
/*
* Copyright 2004-2008 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This adapter sends log output to SLF4J. SLF4J supports multiple
* implementations such as Logback, Log4j, Jakarta Commons Logging (JCL), JDK
* 1.4 logging, x4juli, and Simple Log. To use SLF4J, you need to add the
* required jar files to the classpath, and set the trace level to 4 when opening
* a database:
*
* <pre>
* jdbc:h2:&tilde;/test;TRACE_LEVEL_FILE=4
* </pre>
*
* The logger name is 'h2database'.
*/
public class TraceWriterAdapter implements TraceWriter {
private String name;
private Logger logger = LoggerFactory.getLogger("h2database");
public void setName(String name) {
this.name = name;
}
public boolean isEnabled(int level) {
switch (level) {
case TraceSystem.DEBUG:
return logger.isDebugEnabled();
case TraceSystem.INFO:
return logger.isInfoEnabled();
case TraceSystem.ERROR:
return logger.isErrorEnabled();
}
return false;
}
public void write(int level, String module, String s, Throwable t) {
if (isEnabled(level)) {
if (name != null) {
s = name + ":" + module + " " + s;
} else {
s = module + " " + s;
}
switch (level) {
case TraceSystem.DEBUG:
logger.debug(s, t);
break;
case TraceSystem.INFO:
logger.info(s, t);
break;
case TraceSystem.ERROR:
logger.error(s, t);
break;
}
}
}
}
...@@ -1111,10 +1111,11 @@ SET THROTTLE 200 ...@@ -1111,10 +1111,11 @@ SET THROTTLE 200
SET {TRACE_LEVEL_FILE | TRACE_LEVEL_SYSTEM_OUT} int SET {TRACE_LEVEL_FILE | TRACE_LEVEL_SYSTEM_OUT} int
"," ","
Sets the trace level for file the file or system out stream. Sets the trace level for file the file or system out stream.
Levels: 0=off, 1=error, 2=info, 3=debug. Levels are: 0=off, 1=error, 2=info, 3=debug.
This setting is not persistent. This setting is not persistent.
Admin rights are required to execute this command. Admin rights are required to execute this command.
This setting can be appended to the database URL: jdbc:h2:test;TRACE_LEVEL_SYSTEM_OUT=3 This setting can be appended to the database URL: jdbc:h2:test;TRACE_LEVEL_SYSTEM_OUT=3
To use SLF4J, append ;TRACE_LEVEL_FILE=4 to the database URL when opening the database.
"," ","
SET TRACE_LEVEL_SYSTEM_OUT 3 SET TRACE_LEVEL_SYSTEM_OUT 3
" "
......
...@@ -398,7 +398,7 @@ public class TableData extends Table implements RecordReader { ...@@ -398,7 +398,7 @@ public class TableData extends Table implements RecordReader {
} }
private void traceLock(Session session, boolean exclusive, String s) { private void traceLock(Session session, boolean exclusive, String s) {
if (traceLock.debug()) { if (traceLock.isDebugEnabled()) {
traceLock.debug(session.getId() + " " + (exclusive ? "exclusive write lock" : "shared read lock") + " " + s + " " + getName()); traceLock.debug(session.getId() + " " + (exclusive ? "exclusive write lock" : "shared read lock") + " " + s + " " + getName());
} }
} }
......
...@@ -160,14 +160,12 @@ java org.h2.test.TestAll timer ...@@ -160,14 +160,12 @@ java org.h2.test.TestAll timer
/* /*
test and document log_level_file=4
deactivate triggers during alter table (during re-creating a table) deactivate triggers during alter table (during re-creating a table)
improve javadocs improve javadocs
Pluggable tracing system
test japanese translation
upload jazoon upload jazoon
test case for out of memory (try to corrupt the database using out of memory) test case for out of memory (try to corrupt the database using out of memory)
...@@ -227,7 +225,8 @@ History: ...@@ -227,7 +225,8 @@ History:
for INSERT and UPDATE statements. for INSERT and UPDATE statements.
H2 Shell: DESCRIBE now supports an schema name. H2 Shell: DESCRIBE now supports an schema name.
A subset of the PostgreSQL 'dollar quoting' feature is now supported. A subset of the PostgreSQL 'dollar quoting' feature is now supported.
SLF4J is now supported by using adding TRACE_LEVEL_FILE=4
to the database URL.
Roadmap: Roadmap:
......
...@@ -106,6 +106,9 @@ public class Build extends BuildBase { ...@@ -106,6 +106,9 @@ public class Build extends BuildBase {
download("ext/lucene-core-2.2.0.jar", download("ext/lucene-core-2.2.0.jar",
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar", "http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar",
"47b6eee2e17bd68911e7045896a1c09de0b2dda8"); "47b6eee2e17bd68911e7045896a1c09de0b2dda8");
download("ext/slf4j-api-1.5.0.jar",
"http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar",
"b2df265d02350ecfe87b6c1773c7c4fab2b33505");
} }
private String getVersion() { private String getVersion() {
......
...@@ -508,4 +508,4 @@ informs negotiations collectively omissions trial nor qualify steward neither ...@@ -508,4 +508,4 @@ informs negotiations collectively omissions trial nor qualify steward neither
worldwide everyone additions expense lawsuit checksums jazoon flashback worldwide everyone additions expense lawsuit checksums jazoon flashback
dieguez dfile mvn dversion dgroup dpackaging dartifact durl dpom pom dieguez dfile mvn dversion dgroup dpackaging dartifact durl dpom pom
subpackages slowed deactivate throttled noindex expired arizona export subpackages slowed deactivate throttled noindex expired arizona export
intentional knowing intentional knowing jcl plug facade deployment logback confusion
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论