13 Commits

Author SHA1 Message Date
arthur.blake 6484ab0c10 update CHANGES for 1.2beta1 release date 2010-03-21 02:05:39 +00:00
arthur.blake de7d4acc84 update changes list 2010-03-20 02:47:30 +00:00
arthur.blake 108d89b8bc update copyright 2010-03-20 02:30:32 +00:00
arthur.blake 076a585184 bump version number to 1.2beta1 2010-03-20 01:56:36 +00:00
arthur.blake 1d455b77e6 better handling of dates (don't drop time portion of Date object!!) and use to_date function for Oracle (Issue 14) 2010-03-20 01:53:49 +00:00
arthur.blake e33eb5534f Issue 11; actually use the log4jdbc.dump.sql.maxlinelength parameter! 2009-12-02 19:59:48 +00:00
arthur.blake 15a798c27a performance improvement 2009-12-02 19:29:17 +00:00
arthur.blake e227d3ca26 convert tabs to spaces 2009-12-02 19:28:05 +00:00
arthur.blake 98f98d605c update JDK versions 2009-12-01 23:15:20 +00:00
arthur.blake c19443a574 Issue 8, Issue 9: use better date and timestamp formatting for all database types 2009-12-01 23:14:02 +00:00
arthur.blake de256617a2 check for exception when formatting parameter objects 2009-08-08 19:05:17 +00:00
arthur.blake eac61725f6 bump version number for 1.2 alpha 3 release 2009-08-08 19:02:49 +00:00
arthur.blake f7fa0cdaf4 minor javadoc correction 2009-03-13 02:58:17 +00:00
36 changed files with 236 additions and 239 deletions
+16
View File
@@ -1,3 +1,19 @@
2010-03-20 1.2 beta 1 Release
o Check for exception that should not, but in some cases could
occur when trying to format parameter arguments.
o Use only one type of date format so that time portion of Date
types is not dropped!
o use to_date function for Oracle (Issue 14)
o performance improvements
o fix: respect DumpSqlMaxLineLength option.
o various other fixes (including Issues 8 and 9)
2009-02-26 1.2 alpha 2 Release
o (Issue 1) fix bug where batch of logged SQL wasn't cleared
+7 -2
View File
@@ -4,7 +4,12 @@ setlocal
REM invoke the 1.4 and the 1.6 jvm each in turn
REM for JDBC 3 and JDBC 4 versions respectively
set ANT_HOME=c:\apache-ant-1.6.5
REM BTW, It's not actually necessary to use JDK 1.4
REM if you don't happen to have it laying around,
REM as the ant script properly sets the source
REM and target java versions anyway.
set ANT_HOME=c:\apache-ant-1.7.1
set JAVA_HOME=C:\jdk\1.4.2_18
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
@@ -12,7 +17,7 @@ set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
call ant -Djdbc.level=3 -Djvm.ver=1.4 all
set JAVA_HOME=C:\jdk\1.6.0_11
set JAVA_HOME=C:\jdk\1.6.0_16
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
+7 -5
View File
@@ -9,7 +9,7 @@
built with jdk 1.4.2_13 (for use with jdbc3)
and/or jdk 1.6.0 (for use with jdbc4)
Copyright 2007-2009 Arthur Blake
Copyright 2007-2010 Arthur Blake
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@
<!-- release version -->
<property name="version" value="1.2alpha2"/>
<property name="version" value="1.2beta1"/>
<target name="all" depends="cleancompile,compile,cleanjar,jar"/>
@@ -95,16 +95,18 @@
</target>
<target name="cleanjavadoc">
<target name="cleanjavadoc" description="clean javadoc">
<delete dir="${apidocs}" />
<mkdir dir="${apidocs}" />
</target>
<target name="cleanrelease">
<target name="cleanrelease" description="clean up any release files">
<delete file="../log4jdbc-${version}.zip"/>
<delete file="../log4jdbc-${version}.tar"/>
<delete file="../log4jdbc-${version}.tar.gz"/>
</target>
<target name="clean" depends="cleanrelease,cleanjavadoc,cleanjar,cleancompile" description="clean up all build artifacts"/>
<target name="release" depends="cleanrelease" description="make a complete release distribution (a .jar zip and tar.gz file for release)">
<zip destfile="../log4jdbc-${version}.zip">
+3 -3
View File
@@ -4,16 +4,16 @@ setlocal
REM invoke the 1.4 and the 1.6 jvm each in turn
REM for JDBC 3 and JDBC 4 versions respectively
set ANT_HOME=c:\apache-ant-1.6.5
set ANT_HOME=c:\apache-ant-1.7.1
set ANT_OPTS=-Xmx512m
set JAVA_HOME=C:\jdk\1.4.2_18
set JAVA_HOME=C:\jdk\1.4.2_19
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
call ant -Djdbc.level=3 -Djvm.ver=1.4 ydoc.3
set JAVA_HOME=c:\jdk\1.6.0_11
set JAVA_HOME=c:\jdk\1.6.0_16
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
+2 -2
View File
@@ -2,7 +2,7 @@
rem *************************************************************************************************
rem * *
rem * Copyright 2007-2009 Arthur Blake *
rem * Copyright 2007-2010 Arthur Blake *
rem * *
rem * Licensed under the Apache License, Version 2.0 (the "License"); *
rem * you may not use this file except in compliance with the License. *
@@ -25,4 +25,4 @@ rem * profiling output report.
rem * *
rem *************************************************************************************************
java -Xmx1024m -classpath ..\build\log4jdbc3-1.2alpha2.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
java -Xmx1024m -classpath ..\build\log4jdbc3-1.2beta1.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
+2 -2
View File
@@ -2,7 +2,7 @@
# *************************************************************************************************
# * *
# * Copyright 2007-2009 Arthur Blake *
# * Copyright 2007-2010 Arthur Blake *
# * *
# * Licensed under the Apache License, Version 2.0 (the "License"); *
# * you may not use this file except in compliance with the License. *
@@ -25,4 +25,4 @@
# * *
# *************************************************************************************************
java -Xmx1024m -classpath ../build/log4jdbc3-1.2alpha2.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
java -Xmx1024m -classpath ../build/log4jdbc3-1.2beta1.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package net.sf.log4jdbc;
import java.util.Date;
/**
* RDBMS specifics for the Oracle DB.
*
@@ -26,4 +28,21 @@ class OracleRdbmsSpecifics extends RdbmsSpecifics
{
super();
}
String formatParameterObject(Object object)
{
if (object != null && object instanceof Date)
{
// Use Oracle's to_date function to insure it comes across as a date
//
// for example:
// to_date('12/31/2011 23:59:59.150, 'mm/dd/yyyy hh24:mi:ss.ff3')
return "to_date('" + dateFormat.format(object) + "', " +
"'mm/dd/yyyy hh24:mi:ss.ff3')";
}
else
{
return super.formatParameterObject(object);
}
}
}
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,22 @@ public class PreparedStatementSpy extends StatementSpy implements PreparedStatem
*/
protected void argTraceSet(int i, String typeHelper, Object arg)
{
String tracedArg = rdbmsSpecifics.formatParameterObject(arg);
String tracedArg;
try
{
tracedArg = rdbmsSpecifics.formatParameterObject(arg);
}
catch (Throwable t)
{
// rdbmsSpecifics should NEVER EVER throw an exception!!
// but just in case it does, we trap it.
log.debug("rdbmsSpecifics threw an exception while trying to format a " +
"parameter object [" + arg + "] this is very bad!!! (" +
t.getMessage() + ")");
// backup - so that at least we won't harm the application using us
tracedArg = arg==null?"null":arg.toString();
}
i--; // make the index 0 based
synchronized (argTrace)
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,9 @@
*/
package net.sf.log4jdbc;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Encapsulate sql formatting details about a particular relational database management system so that
@@ -33,6 +34,9 @@ class RdbmsSpecifics
{
}
protected static final DateFormat dateFormat =
new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
/**
* Format an Object that is being bound to a PreparedStatement parameter, for display. The goal is to reformat the
* object in a format that can be re-run against the native SQL client of the particular Rdbms being used. This
@@ -57,11 +61,7 @@ class RdbmsSpecifics
}
else if (object instanceof Date)
{
return object.toString();
}
else if (object instanceof Timestamp)
{
return object.toString();
return "'" + dateFormat.format(object) + "'";
}
else if (object instanceof Boolean)
{
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
* Logger that shows the SQL timing, post execution
*/
private final Logger sqlTimingLogger = LoggerFactory.getLogger("jdbc.sqltiming");
/**
* Logger that shows connection open and close events as well as current number
* of open connections.
@@ -70,10 +70,10 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
private final Logger debugLogger = LoggerFactory.getLogger("log4jdbc.debug");
/**
* Determine if any of the 4 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset |
* jdbc.sqlonly | jdbc.sqltiming.)
* Determine if any of the 5 log4jdbc spy loggers are turned on (jdbc.audit | jdbc.resultset |
* jdbc.sqlonly | jdbc.sqltiming | jdbc.connection)
*
* @return true if any of the 4 spy jdbc/sql loggers are enabled at debug info or error level.
* @return true if any of the 5 spy jdbc/sql loggers are enabled at debug info or error level.
*/
public boolean isJdbcLoggingEnabled()
{
@@ -127,41 +127,35 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
}
}
}
/**
* Called when a jdbc method from a Connection, Statement, PreparedStatement, CallableStatement or ResultSet
* returns.
* Called when a JDBC method from a Connection, Statement, PreparedStatement,
* CallableStatement or ResultSet returns.
*
* @param spy the Spy wrapping the class that called the method that returned.
* @param methodCall a description of the name and call parameters of the method that returned.
* @param returnMsg return value converted to a String for integral types, or String representation for Object
* return types this will be null for void return types.
* @param spy the Spy wrapping the class that called the method that
* returned.
* @param methodCall a description of the name and call parameters of the
* method that returned.
* @param returnMsg return value converted to a String for integral types, or
* String representation for Object. Return types this will
* be null for void return types.
*/
public void methodReturned(Spy spy, String methodCall, String returnMsg)
{
String classType = spy.getClassType();
Integer spyNo = spy.getConnectionNumber();
String header = spyNo + ". " + classType + "." + methodCall + " returned " + returnMsg;
if (ResultSetSpy.classTypeDescription.equals(classType))
Logger logger=ResultSetSpy.classTypeDescription.equals(classType)?
resultSetLogger:jdbcLogger;
if (logger.isInfoEnabled())
{
if (resultSetLogger.isDebugEnabled())
String header = spy.getConnectionNumber() + ". " + classType + "." +
methodCall + " returned " + returnMsg;
if (logger.isDebugEnabled())
{
resultSetLogger.debug(header + " " + getDebugInfo());
logger.debug(header + " " + getDebugInfo());
}
else if (resultSetLogger.isInfoEnabled())
else
{
resultSetLogger.info(header);
}
}
else
{
if (jdbcLogger.isDebugEnabled())
{
jdbcLogger.debug(header + " " + getDebugInfo());
}
else if (jdbcLogger.isInfoEnabled())
{
jdbcLogger.info(header);
logger.info(header);
}
}
}
@@ -178,11 +172,11 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
}
private static String nl = System.getProperty("line.separator");
/**
* Determine if the given sql should be logged or not
* based on the various DumpSqlXXXXXX flags.
*
*
* @param sql SQL to test.
* @return true if the SQL should be logged, false if not.
*/
@@ -199,7 +193,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
return false;
}
sql = sql.substring(0,6).toLowerCase();
return
return
(DriverSpy.DumpSqlSelect && "select".equals(sql)) ||
(DriverSpy.DumpSqlInsert && "insert".equals(sql)) ||
(DriverSpy.DumpSqlUpdate && "update".equals(sql)) ||
@@ -219,7 +213,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
if (!DriverSpy.DumpSqlFilteringOn || shouldSqlBeLogged(sql))
{
sql = processSql(sql);
if (sqlOnlyLogger.isDebugEnabled())
{
sqlOnlyLogger.debug(getDebugInfo() + nl + spy.getConnectionNumber() + ". " + sql);
@@ -232,9 +226,9 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
}
/**
* Break an SQL statement up into multiple lines in an attempt to make it
* Break an SQL statement up into multiple lines in an attempt to make it
* more readable
*
*
* @param sql SQL to break up.
* @return SQL broken up into multiple lines
*/
@@ -247,7 +241,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
sql = sql.trim();
StringBuffer output = new StringBuffer();
StringBuffer output = new StringBuffer();
if (DriverSpy.DumpSqlMaxLineLength <= 0)
{
@@ -259,16 +253,16 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
StringTokenizer st = new StringTokenizer(sql);
String token;
int linelength = 0;
while (st.hasMoreElements())
{
token = (String) st.nextElement();
output.append(token);
linelength += token.length();
output.append(" ");
linelength++;
if (linelength > 90)
if (linelength > DriverSpy.DumpSqlMaxLineLength)
{
output.append("\n");
linelength = 0;
@@ -280,7 +274,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
{
output.append(";");
}
return output.toString();
}
@@ -298,7 +292,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
*/
public void sqlTimingOccured(Spy spy, long execTime, String methodCall, String sql)
{
if (sqlTimingLogger.isErrorEnabled() &&
if (sqlTimingLogger.isErrorEnabled() &&
(!DriverSpy.DumpSqlFilteringOn || shouldSqlBeLogged(sql)))
{
if (DriverSpy.SqlTimingErrorThresholdEnabled &&
@@ -358,7 +352,7 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
out.append(spy.getConnectionNumber());
out.append(". ");
}
// NOTE: if both sql dump and sql timing dump are on, the processSql
// algorithm will run TWICE once at the beginning and once at the end
// this is not very efficient but usually
@@ -399,8 +393,8 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
StringBuffer dump = new StringBuffer();
/**
* The DumpFullDebugStackTrace option is useful in some situations when
* we want to see the full stack trace in the debug info- watch out
* The DumpFullDebugStackTrace option is useful in some situations when
* we want to see the full stack trace in the debug info- watch out
* though as this will make the logs HUGE!
*/
if (DriverSpy.DumpFullDebugStackTrace)
@@ -476,14 +470,14 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
/**
* Called whenever a new connection spy is created.
*
*
* @param spy ConnectionSpy that was created.
*/
public void connectionOpened(Spy spy)
{
if (connectionLogger.isDebugEnabled())
{
connectionLogger.info(spy.getConnectionNumber() + ". Connection opened " +
connectionLogger.info(spy.getConnectionNumber() + ". Connection opened " +
getDebugInfo());
connectionLogger.debug(ConnectionSpy.getOpenConnectionsDump());
}
@@ -495,14 +489,14 @@ public class Slf4jSpyLogDelegator implements SpyLogDelegator
/**
* Called whenever a connection spy is closed.
*
*
* @param spy ConnectionSpy that was closed.
*/
public void connectionClosed(Spy spy)
{
if (connectionLogger.isDebugEnabled())
{
connectionLogger.info(spy.getConnectionNumber() + ". Connection closed " +
connectionLogger.info(spy.getConnectionNumber() + ". Connection closed " +
getDebugInfo());
connectionLogger.debug(ConnectionSpy.getOpenConnectionsDump());
}
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,56 +15,15 @@
*/
package net.sf.log4jdbc;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
/**
* Formatting for SQL Server databases.
* RDBMS specifics for the Sql Server DB.
*
* @author Arthur Blake
*/
class SqlServerRdbmsSpecifics extends RdbmsSpecifics
{
/**
* Default constructor.
*/
SqlServerRdbmsSpecifics()
{
super();
}
private static final DateFormat sqlServerDateFormat = new SimpleDateFormat("MM/dd/yyyy");
private static final DateFormat sqlServerTimestampFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
/**
* Format an Object that is being bound to a PreparedStatement parameter, for display. The goal is to reformat the
* object in a format that can be re-run against the native SQL client of the particular Rdbms being used. This
* class should be extended to provide formatting instances that format objects correctly for different RDBMS
* types.
*
* @param object jdbc object to be formatted.
* @return formatted dump of the object.
*/
String formatParameterObject(Object object)
{
if (object == null)
{
return super.formatParameterObject(object);
}
if (object instanceof Date)
{
return "'" + sqlServerDateFormat.format(object) + "'";
}
else if (object instanceof Timestamp)
{
return "'" + sqlServerTimestampFormat.format(object) + "'";
}
else
{
return super.formatParameterObject(object);
}
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007-2009 Arthur Blake
* Copyright 2007-2010 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

Some files were not shown because too many files have changed in this diff Show More