Commit patches provided by Antonio Petrelli - thanks Antonio
Bugzilla issues:
47595: POMs of companions have problems
47599: TestLogMF fails with Italian locale
47600: ConnectionSourceSkeleton does not close connection after discovery
47615: The DB Appender does not work under Oracle
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk@821364 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 0f69462..c6073f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,8 +83,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.2</source>
- <target>1.1</target>
+ <source>1.4</source>
+ <target>1.4</target>
</configuration>
</plugin>
<plugin>
@@ -112,7 +112,7 @@
<id>untag-site</id>
<configuration>
<tasks>
- <taskdef name="replaceregexp" classname="org.apache.tools.ant.taskdefs.optional.ReplaceRegExp" />
+ <taskdef name="replaceregexp" classname="org.apache.tools.ant.taskdefs.optional.ReplaceRegExp" />
<replaceregexp file="target/site/source-repository.html" match="/tags/[^ "'<]*" replace="/trunk" flags="g"/>
<replaceregexp match="-- Generated by (.*) on .*--" replace="-- Generated by \1 --" flags="g">
<fileset dir="target/site/apidocs" includes="**/*.html"/>
@@ -160,7 +160,7 @@
<version>1.0b2</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
@@ -171,6 +171,7 @@
</configuration>
<executions>
<execution>
+ <phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
@@ -197,7 +198,7 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
<dependencies>
@@ -216,13 +217,31 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.16-SNAPSHOT</version>
- </dependency>
+ <version>1.2.15</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jdmk</groupId>
+ <artifactId>jmxtools</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jmx</groupId>
+ <artifactId>jmxri</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>mail</artifactId>
+ <groupId>javax.mail</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-component</artifactId>
<version>1.0-SNAPSHOT</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
@@ -232,7 +251,7 @@
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
@@ -241,7 +260,7 @@
</dependency>
</dependencies>
<reporting>
- <excludeDefaults>true</excludeDefaults>
+ <excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
@@ -280,7 +299,7 @@
<configuration>
<issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
</configuration>
- </plugin>
+ </plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
</plugin>
@@ -298,6 +317,6 @@
<id>logging.site</id>
<url>scp://localhost/${user.dir}/target/site-deploy</url>
</site>
- </distributionManagement>
+ </distributionManagement>
</project>
diff --git a/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java b/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java
index fd4b014..a5abecb 100644
--- a/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java
+++ b/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java
@@ -17,18 +17,21 @@
package org.apache.log4j.db;
-import org.apache.log4j.db.dialect.Util;
-import org.apache.log4j.spi.ComponentBase;
-
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
+import org.apache.log4j.db.dialect.Util;
+import org.apache.log4j.spi.ComponentBase;
+
/**
* @author Ceki Gülcü
*/
public abstract class ConnectionSourceSkeleton extends ComponentBase implements ConnectionSource {
+
+ private Boolean overriddenSupportsGetGeneratedKeys = null;
+
private String user = null;
private String password = null;
@@ -43,8 +46,9 @@
*
*/
public void discoverConnnectionProperties() {
+ Connection connection = null;
try {
- Connection connection = getConnection();
+ connection = getConnection();
if (connection == null) {
getLogger().warn("Could not get a conneciton");
return;
@@ -52,11 +56,18 @@
DatabaseMetaData meta = connection.getMetaData();
Util util = new Util();
util.setLoggerRepository(repository);
- supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta);
+ if (overriddenSupportsGetGeneratedKeys != null) {
+ supportsGetGeneratedKeys = overriddenSupportsGetGeneratedKeys
+ .booleanValue();
+ } else {
+ supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta);
+ }
supportsBatchUpdates = util.supportsBatchUpdates(meta);
dialectCode = Util.discoverSQLDialect(meta);
} catch (SQLException se) {
getLogger().warn("Could not discover the dialect to use.", se);
+ } finally {
+ DBHelper.closeConnection(connection);
}
}
@@ -102,6 +113,35 @@
}
/**
+ * Returns the "overridden" value of "supportsGetGeneratedKeys" property of
+ * the JDBC driver. In certain cases, getting (e.g. Oracle 10g) generated keys
+ * does not work because it returns the ROWID, not the value of the sequence.
+ *
+ * @return A non null string, with "true" or "false" value, if overridden,
+ * <code>null</code> if not overridden.
+ */
+ public String getOverriddenSupportsGetGeneratedKeys() {
+ return overriddenSupportsGetGeneratedKeys != null ? overriddenSupportsGetGeneratedKeys
+ .toString()
+ : null;
+ }
+
+ /**
+ * Sets the "overridden" value of "supportsGetGeneratedKeys" property of the
+ * JDBC driver. In certain cases, getting (e.g. Oracle 10g) generated keys
+ * does not work because it returns the ROWID, not the value of the sequence.
+ *
+ * @param overriddenSupportsGetGeneratedKeys
+ * A non null string, with "true" or "false" value, if overridden,
+ * <code>null</code> if not overridden.
+ */
+ public void setOverriddenSupportsGetGeneratedKeys(
+ String overriddenSupportsGetGeneratedKeys) {
+ this.overriddenSupportsGetGeneratedKeys = Boolean
+ .valueOf(overriddenSupportsGetGeneratedKeys);
+ }
+
+ /**
* Does this connection support batch updates?
*/
public final boolean supportsBatchUpdates() {
diff --git a/src/main/java/org/apache/log4j/db/dialect/oracle.sql b/src/main/java/org/apache/log4j/db/dialect/oracle.sql
index 81fe9c5..ae307bf 100644
--- a/src/main/java/org/apache/log4j/db/dialect/oracle.sql
+++ b/src/main/java/org/apache/log4j/db/dialect/oracle.sql
@@ -38,7 +38,7 @@
FOR EACH ROW
BEGIN
SELECT logging_event_id_seq.nextval
- INTO :new.sequence_number$ FROM dual
+ INTO :new.sequence_number FROM dual;
END;
CREATE TABLE logging_event_property
@@ -58,4 +58,4 @@
PRIMARY KEY(event_id, i),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
);
-
\ No newline at end of file
+