This is an automated email from the ASF dual-hosted git repository. grobmeier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git
commit eec06851b1997686ee4e45724e274da704b93951 Author: Christian Grobmeier <[email protected]> AuthorDate: Thu Dec 21 19:00:55 2023 +0100 removed unused DB package --- .../java/org/apache/log4j/db/ConnectionSource.java | 70 ---- .../apache/log4j/db/ConnectionSourceSkeleton.java | 149 ------- .../org/apache/log4j/db/CustomSQLDBReceiver.java | 465 --------------------- src/main/java/org/apache/log4j/db/DBAppender.java | 370 ---------------- src/main/java/org/apache/log4j/db/DBHelper.java | 67 --- src/main/java/org/apache/log4j/db/DBReceiver.java | 139 ------ .../java/org/apache/log4j/db/DBReceiverJob.java | 224 ---------- .../log4j/db/DataSourceConnectionSource.java | 105 ----- .../log4j/db/DriverManagerConnectionSource.java | 137 ------ .../org/apache/log4j/db/JNDIConnectionSource.java | 144 ------- .../org/apache/log4j/db/dialect/HSQLDBDialect.java | 31 -- .../org/apache/log4j/db/dialect/MsSQLDialect.java | 34 -- .../org/apache/log4j/db/dialect/MySQLDialect.java | 29 -- .../org/apache/log4j/db/dialect/OracleDialect.java | 33 -- .../apache/log4j/db/dialect/PostgreSQLDialect.java | 34 -- .../org/apache/log4j/db/dialect/SQLDialect.java | 26 -- .../org/apache/log4j/db/dialect/SybaseDialect.java | 31 -- .../java/org/apache/log4j/db/dialect/Util.java | 119 ------ src/main/java/org/apache/log4j/db/dialect/db2.sql | 64 --- src/main/java/org/apache/log4j/db/dialect/db2l.sql | 61 --- .../java/org/apache/log4j/db/dialect/hsqldb.sql | 60 --- .../java/org/apache/log4j/db/dialect/mssql.sql | 61 --- .../java/org/apache/log4j/db/dialect/mysql.sql | 71 ---- .../java/org/apache/log4j/db/dialect/oracle.sql | 77 ---- .../org/apache/log4j/db/dialect/postgresql.sql | 63 --- .../java/org/apache/log4j/db/package-info.java | 28 -- 26 files changed, 2692 deletions(-) diff --git a/src/main/java/org/apache/log4j/db/ConnectionSource.java b/src/main/java/org/apache/log4j/db/ConnectionSource.java deleted file mode 100644 index d59a1cc..0000000 --- a/src/main/java/org/apache/log4j/db/ConnectionSource.java +++ /dev/null @@ -1,70 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.spi.Component; -//import org.apache.log4j.spi.OptionHandler; -// -//import java.sql.Connection; -//import java.sql.SQLException; -// -// -///** -// * The {@code ConnectionSource} interface provides a pluggable means of -// * transparently obtaining JDBC {@link java.sql.Connection}s for log4j classes -// * that require the use of a {@link java.sql.Connection}. -// * -// * @author <a href="mailto:[email protected]">Ray DeCampo</a> -// */ -//public interface ConnectionSource extends Component, OptionHandler { -// -// int UNKNOWN_DIALECT = 0; -// int POSTGRES_DIALECT = 1; -// int MYSQL_DIALECT = 2; -// int ORACLE_DIALECT = 3; -// int MSSQL_DIALECT = 4; -// int HSQL_DIALECT = 5; -// -// /** -// * Obtain a {@link java.sql.Connection} for use. The client is -// * responsible for closing the {@link java.sql.Connection} when it is no -// * longer required. -// * -// * @throws SQLException if a {@link java.sql.Connection} could not be -// * obtained -// */ -// Connection getConnection() throws SQLException; -// -// /** -// * Get the SQL dialect that should be used for this connection. Note that the -// * dialect is not needed if the JDBC driver supports the getGeneratedKeys -// * method. -// */ -// int getSQLDialectCode(); -// -// /** -// * If the connection supports the JDBC 3.0 getGeneratedKeys method, then -// * we do not need any specific dialect support. -// */ -// boolean supportsGetGeneratedKeys(); -// -// /** -// * If the connection does not support batch updates, we will avoid using them. -// */ -// boolean supportsBatchUpdates(); -//} diff --git a/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java b/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java deleted file mode 100644 index 3fc8f1e..0000000 --- a/src/main/java/org/apache/log4j/db/ConnectionSourceSkeleton.java +++ /dev/null @@ -1,149 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//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; -// -// -///** -// * @author Ceki Gülcü -// */ -//public abstract class ConnectionSourceSkeleton extends ComponentBase implements ConnectionSource { -// -// private Boolean overriddenSupportsGetGeneratedKeys = null; -// -// private String user = null; -// private String password = null; -// -// // initially we have an unkonw dialect -// private int dialectCode = UNKNOWN_DIALECT; -// private boolean supportsGetGeneratedKeys = false; -// private boolean supportsBatchUpdates = false; -// -// -// /** -// * Learn relevant information about this connection source. -// */ -// public void discoverConnnectionProperties() { -// Connection connection = null; -// try { -// connection = getConnection(); -// if (connection == null) { -// getLogger().warn("Could not get a conneciton"); -// return; -// } -// DatabaseMetaData meta = connection.getMetaData(); -// Util util = new Util(); -// util.setLoggerRepository(repository); -// if (overriddenSupportsGetGeneratedKeys != null) { -// supportsGetGeneratedKeys = overriddenSupportsGetGeneratedKeys; -// } 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); -// } -// } -// -// /** -// * Does this connection support the JDBC Connection.getGeneratedKeys method? -// */ -// public final boolean supportsGetGeneratedKeys() { -// return supportsGetGeneratedKeys; -// } -// -// public final int getSQLDialectCode() { -// return dialectCode; -// } -// -// /** -// * Get the password for this connection source. -// */ -// public final String getPassword() { -// return password; -// } -// -// /** -// * Sets the password. -// * -// * @param password The password to set -// */ -// public final void setPassword(final String password) { -// this.password = password; -// } -// -// /** -// * Get the user for this connection source. -// */ -// public final String getUser() { -// return user; -// } -// -// /** -// * Sets the username. -// * -// * @param username The username to set -// */ -// public final void setUser(final String username) { -// this.user = username; -// } -// -// /** -// * 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() { -// return supportsBatchUpdates; -// } -//} diff --git a/src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java b/src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java deleted file mode 100644 index d8463c0..0000000 --- a/src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java +++ /dev/null @@ -1,465 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.Level; -//import org.apache.log4j.Logger; -//import org.apache.log4j.plugins.Pauseable; -//import org.apache.log4j.plugins.Receiver; -//import org.apache.log4j.scheduler.Job; -//import org.apache.log4j.scheduler.Scheduler; -//import org.apache.log4j.spi.LocationInfo; -//import org.apache.log4j.spi.LoggerRepositoryEx; -//import org.apache.log4j.spi.LoggingEvent; -//import org.apache.log4j.spi.ThrowableInformation; -//import org.apache.log4j.xml.DOMConfigurator; -//import org.apache.log4j.xml.UnrecognizedElementHandler; -//import org.w3c.dom.Element; -// -//import java.sql.Connection; -//import java.sql.ResultSet; -//import java.sql.SQLException; -//import java.sql.Statement; -//import java.util.Hashtable; -//import java.util.Properties; -//import java.util.StringTokenizer; -// -///** -// * Converts log data stored in a database into LoggingEvents. -// * <p> -// * <b>NOTE:</b> This receiver cannot yet be created through Chainsaw's receiver panel. -// * It must be created through an XML configuration file. -// * <p> -// * This receiver supports database configuration via ConnectionSource, in the -// * org.apache.log4j.db package: DriverManagerConnectionSource, -// * DataSourceConnectionSource, JNDIConnectionSource -// * <p> -// * This database receiver differs from DBReceiver in that this receiver relies -// * on custom SQL to retrieve logging event data, where DBReceiver requires the -// * use of a log4j-defined schema. -// * <p> -// * A 'refreshMillis' int parameter controls SQL execution. If 'refreshMillis' is -// * zero (the default), the receiver will run only one time. If it is set to any -// * other numeric value, the SQL will be executed on a recurring basis every -// * 'refreshMillis' milliseconds. -// * <p> -// * The receiver closes the connection and acquires a new connection on each -// * execution of the SQL (use pooled connections if possible). -// * <p> -// * If the SQL will be executing on a recurring basis, specify the IDField param - -// * the column name holding the unique identifier (int) representing the logging -// * event. -// * <p> -// * As events are retrieved, the column represented by IDField is examined and -// * the largest value is held and used by the next execution of the SQL statement -// * to avoid retrieving previously processed events. -// * <p> -// * As an example, the IDField references a 'COUNTER' (int, auto-increment, -// * unique) column. The first execution of the SQL statement returns 500 rows, -// * with a final value in the COUNTER field of 500. -// * <p> -// * The SQL statement is manipulated prior to the next execution, adding ' WHERE -// * COUNTER > 500' to the statement to avoid retrieval of previously processed -// * events. -// * <p> -// * The select statement must provide ALL fields which define a LoggingEvent. -// * <p> -// * The SQL statement MUST include the columns: LOGGER, TIMESTAMP, LEVEL, THREAD, -// * MESSAGE, NDC, MDC, CLASS, METHOD, FILE, LINE, PROPERTIES, THROWABLE -// * <p> -// * Use ' AS ' in the SQL statement to alias the SQL's column names to match your -// * database schema. (see example below). -// * <p> -// * Include all fields in the SQL statement, even if you don't have data for the -// * field (specify an empty string as the value for columns which you don't have -// * data). -// * <p> -// * The TIMESTAMP column must be a datetime. -// * <p> -// * Both a PROPERTIES column and an MDC column are supported. These fields -// * represent Maps on the logging event, but require the use of string -// * concatenation database functions to hold the (possibly multiple) name/value -// * pairs in the column. -// * <p> -// * For example, to include both 'userid' and 'lastname' properties in the -// * logging event (from either the PROPERTIES or MDC columns), the name/value -// * pairs must be concatenated together by your database. -// * <p> -// * The resulting PROPERTIES or MDC column must have data in this format: {{name, -// * value, name2, value2}} -// * <p> -// * The resulting PROPERTIES column would contain this text: {{userid, someone, -// * lastname, mylastname}} -// * <p> -// * Here is an example of concatenating a PROPERTIES or MDC column using MySQL's -// * concat function, where the 'application' and 'hostname' parameters were fixed -// * text, but the 'log4jid' key's value is the value of the COUNTER column: -// * <p> -// * concat("{{application,databaselogs,hostname,mymachine,log4jid,", COUNTER, -// * "}}") as PROPERTIES -// * <p> -// * log4jid is a special property that is used by Chainsaw to represent an 'ID' -// * field. Specify this property to ensure you can map events in Chainsaw to -// * events in the database if you need to go back and view events at a later time -// * or save the events to XML for later analysis. -// * <p> -// * Here is a complete MySQL SQL statement which can be used to provide events to -// * Chainsaw (note how in the example below, there is no column in logtable representing the throwable, so an -// * empty string is passed in and an ALIAS is still defined): -// * <p> -// * select myloggercolumn as LOGGER, mytimestampcolumn as TIMESTAMP, mylevelcolumn as LEVEL, mythreadcolumn as -// * THREAD, mymessagecolumn as MESSAGE, myndccolumn as NDC, mymdccolumn as MDC, myclasscolumn as CLASS, mymethodcolumn as -// * METHOD, myfilecolumn as FILE, mylinecolumn as LINE, -// * concat("{{application,databaselogs,hostname,mymachine, log4jid,", -// * COUNTER,"}}") as PROPERTIES, "" as THROWABLE from logtable -// * <p> -// * -// * @author Scott Deboy <[email protected]> -// * <p> -// */ -//public class CustomSQLDBReceiver extends Receiver implements Pauseable, UnrecognizedElementHandler { -// -// protected volatile Connection connection = null; -// -// protected String sqlStatement = ""; -// -// /** -// * By default we refresh data every 1000 milliseconds. -// * -// * @see #setRefreshMillis -// */ -// static int DEFAULT_REFRESH_MILLIS = 1000; -// -// int refreshMillis = DEFAULT_REFRESH_MILLIS; -// -// protected String idField = null; -// -// int lastID = -1; -// -// private static final String WHERE_CLAUSE = " WHERE "; -// -// private static final String AND_CLAUSE = " AND "; -// -// private boolean whereExists = false; -// -// private boolean paused = false; -// -// private ConnectionSource connectionSource; -// -// public static final String LOG4J_ID_KEY = "log4jid"; -// -// private Job customReceiverJob; -// -// public void activateOptions() { -// -// if (connectionSource == null) { -// throw new IllegalStateException( -// "CustomSQLDBReceiver cannot function without a connection source"); -// } -// whereExists = (sqlStatement.toUpperCase().contains(WHERE_CLAUSE)); -// -// customReceiverJob = new CustomReceiverJob(); -// -// if (this.repository == null) { -// throw new IllegalStateException( -// "CustomSQLDBReceiver cannot function without a reference to its owning repository"); -// } -// -// -// if (repository instanceof LoggerRepositoryEx) { -// Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); -// -// scheduler.schedule( -// customReceiverJob, System.currentTimeMillis() + 500, refreshMillis); -// } -// -// } -// -// void closeConnection() { -// if (connection != null) { -// try { -// // LogLog.warn("closing the connection. ", new Exception("x")); -// connection.close(); -// } catch (SQLException sqle) { -// // nothing we can do here -// } -// } -// } -// -// public void setRefreshMillis(int refreshMillis) { -// this.refreshMillis = refreshMillis; -// } -// -// public int getRefreshMillis() { -// return refreshMillis; -// } -// -// /** -// * @return Returns the connectionSource. -// */ -// public ConnectionSource getConnectionSource() { -// return connectionSource; -// } -// -// /** -// * @param connectionSource The connectionSource to set. -// */ -// public void setConnectionSource(ConnectionSource connectionSource) { -// this.connectionSource = connectionSource; -// } -// -// public void close() { -// try { -// if ((connection != null) && !connection.isClosed()) { -// connection.close(); -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// connection = null; -// } -// } -// -// public void finalize() throws Throwable { -// super.finalize(); -// close(); -// } -// -// /* -// * (non-Javadoc) -// * -// * @see org.apache.log4j.plugins.Plugin#shutdown() -// */ -// public void shutdown() { -// getLogger().info("removing receiverJob from the Scheduler."); -// -// if (this.repository instanceof LoggerRepositoryEx) { -// Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); -// scheduler.delete(customReceiverJob); -// } -// -// lastID = -1; -// } -// -// public void setSql(String s) { -// sqlStatement = s; -// } -// -// public String getSql() { -// return sqlStatement; -// } -// -// public void setIDField(String id) { -// idField = id; -// } -// -// public String getIDField() { -// return idField; -// } -// -// public synchronized void setPaused(boolean p) { -// paused = p; -// } -// -// public synchronized boolean isPaused() { -// return paused; -// } -// -// class CustomReceiverJob implements Job { -// public void execute() { -// int oldLastID = lastID; -// try { -// connection = connectionSource.getConnection(); -// Statement statement = connection.createStatement(); -// -// Logger eventLogger; -// long timeStamp; -// String level; -// String threadName; -// Object message; -// String ndc; -// Hashtable<String, String> mdc; -// String[] throwable; -// String className; -// String methodName; -// String fileName; -// String lineNumber; -// Hashtable<String, String> properties; -// -// String currentSQLStatement; -// if (whereExists) { -// currentSQLStatement = sqlStatement + AND_CLAUSE + idField -// + " > " + lastID; -// } else { -// currentSQLStatement = sqlStatement + WHERE_CLAUSE + idField -// + " > " + lastID; -// } -// -// ResultSet rs = statement.executeQuery(currentSQLStatement); -// -// int i = 0; -// while (rs.next()) { -// // add a small break every 1000 received events -// if (++i == 1000) { -// synchronized (this) { -// try { -// // add a delay -// wait(300); -// } catch (InterruptedException ie) { -// } -// i = 0; -// } -// } -// eventLogger = Logger.getLogger(rs.getString("LOGGER")); -// timeStamp = rs.getTimestamp("TIMESTAMP").getTime(); -// -// level = rs.getString("LEVEL"); -// threadName = rs.getString("THREAD"); -// message = rs.getString("MESSAGE"); -// ndc = rs.getString("NDC"); -// -// String mdcString = rs.getString("MDC"); -// mdc = new Hashtable<>(); -// -// if (mdcString != null) { -// // support MDC being wrapped in {{name, value}} -// // or -// // just name, value -// if ((mdcString.contains("{{")) -// && (mdcString.contains("}}"))) { -// mdcString = mdcString -// .substring(mdcString.indexOf("{{") + 2, -// mdcString.indexOf("}}")); -// } -// -// StringTokenizer tok = new StringTokenizer(mdcString, -// ","); -// -// while (tok.countTokens() > 1) { -// mdc.put(tok.nextToken(), tok.nextToken()); -// } -// } -// -// throwable = new String[]{rs.getString("THROWABLE")}; -// className = rs.getString("CLASS"); -// methodName = rs.getString("METHOD"); -// fileName = rs.getString("FILE"); -// lineNumber = rs.getString("LINE"); -// -// // if properties are provided in the -// // SQL they can be used here (for example, to route -// // events to a unique tab in -// // Chainsaw if the machinename and/or appname -// // property -// // are set) -// String propertiesString = rs.getString("PROPERTIES"); -// properties = new Hashtable<>(); -// -// if (propertiesString != null) { -// // support properties being wrapped in {{name, -// // value}} or just name, value -// if ((propertiesString.contains("{{")) -// && (propertiesString.contains("}}"))) { -// propertiesString = propertiesString.substring( -// propertiesString.indexOf("{{") + 2, -// propertiesString.indexOf("}}")); -// } -// -// StringTokenizer tok2 = new StringTokenizer( -// propertiesString, ","); -// while (tok2.countTokens() > 1) { -// String tokenName = tok2.nextToken(); -// String value = tok2.nextToken(); -// if (tokenName.equals(LOG4J_ID_KEY)) { -// try { -// int thisInt = Integer.parseInt(value); -// value = String.valueOf(thisInt); -// if (thisInt > lastID) { -// lastID = thisInt; -// } -// } catch (Exception e) { -// } -// } -// properties.put(tokenName, value); -// } -// } -// -// Level levelImpl = Level.toLevel(level); -// -// -// LocationInfo locationInfo = new LocationInfo(fileName, -// className, methodName, lineNumber); -// -// ThrowableInformation throwableInfo = new ThrowableInformation( -// throwable); -// -// properties.putAll(mdc); -// -// LoggingEvent event = new LoggingEvent(eventLogger.getName(), -// eventLogger, timeStamp, levelImpl, message, -// threadName, -// throwableInfo, -// ndc, -// locationInfo, -// properties); -// -// doPost(event); -// } -// //log when rows are retrieved -// if (lastID != oldLastID) { -// getLogger().debug("lastID: " + lastID); -// } -// -// statement.close(); -// } catch (SQLException sqle) { -// getLogger() -// .error("*************Problem receiving events", sqle); -// } finally { -// closeConnection(); -// } -// -// // if paused, loop prior to executing sql query -// synchronized (this) { -// while (isPaused()) { -// try { -// wait(1000); -// } catch (InterruptedException ie) { -// } -// } -// } -// } -// } -// -// /** -// * {@inheritDoc} -// */ -// public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { -// if ("connectionSource".equals(element.getNodeName())) { -// Object instance = -// DOMConfigurator.parseElement(element, props, ConnectionSource.class); -// if (instance instanceof ConnectionSource) { -// ConnectionSource source = (ConnectionSource) instance; -// source.activateOptions(); -// setConnectionSource(source); -// } -// return true; -// } -// return false; -// } -// -//} diff --git a/src/main/java/org/apache/log4j/db/DBAppender.java b/src/main/java/org/apache/log4j/db/DBAppender.java deleted file mode 100644 index c77cd7e..0000000 --- a/src/main/java/org/apache/log4j/db/DBAppender.java +++ /dev/null @@ -1,370 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.AppenderSkeleton; -//import org.apache.log4j.db.dialect.SQLDialect; -//import org.apache.log4j.db.dialect.Util; -//import org.apache.log4j.helpers.LogLog; -//import org.apache.log4j.spi.LocationInfo; -//import org.apache.log4j.spi.LoggingEvent; -//import org.apache.log4j.xml.DOMConfigurator; -//import org.apache.log4j.xml.UnrecognizedElementHandler; -//import org.w3c.dom.Element; -// -//import java.sql.Connection; -//import java.sql.PreparedStatement; -//import java.sql.ResultSet; -//import java.sql.Statement; -//import java.util.Properties; -//import java.util.Set; -// -// -///** -// * The DBAppender inserts loggin events into three database tables in a format -// * independent of the Java programming language. The three tables that -// * DBAppender inserts to must exists before DBAppender can be used. These tables -// * may be created with the help of SQL scripts found in the -// * <em>src/java/org/apache/log4j/db/dialect</em> directory. There is a -// * specific script for each of the most popular database systems. If the script -// * for your particular type of database system is missing, it should be quite -// * easy to write one, taking example on the already existing scripts. If you -// * send them to us, we will gladly include missing scripts in future releases. -// * <p> -// * <p> -// * If the JDBC driver you are using supports the -// * {@link java.sql.Statement#getGeneratedKeys}method introduced in JDBC 3.0 -// * specification, then you are all set. Otherwise, there must be an -// * {@link SQLDialect}appropriate for your database system. Currently, we have -// * dialects for PostgreSQL, MySQL, Oracle and MsSQL. As mentioed previously, an -// * SQLDialect is required only if the JDBC driver for your database system does -// * not support the {@link java.sql.Statement#getGeneratedKeys getGeneratedKeys} -// * method. -// * </p> -// * <p> -// * <table border="1" cellpadding="4"> -// * <caption>supported dialects</caption> -// * <tr> -// * <th>RDBMS</th> -// * <th>supports <br><code>getGeneratedKeys()</code> method</th> -// * <th>specific <br>SQLDialect support</th> -// * <tr> -// * <tr> -// * <td>PostgreSQL</td> -// * <td align="center">NO</td> -// * <td>present and used</td> -// * <tr> -// * <tr> -// * <td>MySQL</td> -// * <td align="center">YES</td> -// * <td>present, but not actually needed or used</td> -// * <tr> -// * <tr> -// * <td>Oracle</td> -// * <td align="center">YES</td> -// * <td>present, but not actually needed or used</td> -// * <tr> -// * <tr> -// * <td>DB2</td> -// * <td align="center">YES</td> -// * <td>not present, and not needed or used</td> -// * <tr> -// * <tr> -// * <td>MsSQL</td> -// * <td align="center">YES</td> -// * <td>not present, and not needed or used</td> -// * <tr> -// * <tr> -// * <td>HSQL</td> -// * <td align="center">NO</td> -// * <td>present and used</td> -// * <tr> -// * <p> -// * </table> -// * <p> -// * <b>Performance: </b> Experiments show that writing a single event into the -// * database takes approximately 50 milliseconds, on a "standard" PC. If pooled -// * connections are used, this figure drops to under 10 milliseconds. Note that -// * most JDBC drivers already ship with connection pooling support. -// * </p> -// * <p> -// * <p> -// * <p> -// * <p> -// * <b>Configuration </b> DBAppender can be configured programmatically, or using -// * {@link org.apache.log4j.xml.DOMConfigurator JoranConfigurator}. Example -// * scripts can be found in the <em>tests/input/db</em> directory. -// * -// * @author Ceki Gülcü -// * @author Ray DeCampo -// */ -//public class DBAppender extends AppenderSkeleton implements UnrecognizedElementHandler { -// static final String insertPropertiesSQL = -// "INSERT INTO logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)"; -// static final String insertExceptionSQL = -// "INSERT INTO logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)"; -// static final String insertSQL; -// -// -// static { -// String sql = "INSERT INTO logging_event (" + -// "sequence_number, " + -// "timestamp, " + -// "rendered_message, " + -// "logger_name, " + -// "level_string, " + -// "ndc, " + -// "thread_name, " + -// "reference_flag, " + -// "caller_filename, " + -// "caller_class, " + -// "caller_method, " + -// "caller_line) " + -// " VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?)"; -// insertSQL = sql; -// } -// -// ConnectionSource connectionSource; -// boolean cnxSupportsGetGeneratedKeys = false; -// boolean cnxSupportsBatchUpdates = false; -// SQLDialect sqlDialect; -// boolean locationInfo = false; -// -// -// public DBAppender() { -// super(false); -// } -// -// public void activateOptions() { -// LogLog.debug("DBAppender.activateOptions called"); -// -// if (connectionSource == null) { -// throw new IllegalStateException( -// "DBAppender cannot function without a connection source"); -// } -// -// sqlDialect = Util.getDialectFromCode(connectionSource.getSQLDialectCode()); -// cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); -// cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); -// if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { -// throw new IllegalStateException( -// "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); -// } -// -// // all nice and dandy on the eastern front -// super.activateOptions(); -// } -// -// /** -// * @return Returns the connectionSource. -// */ -// public ConnectionSource getConnectionSource() { -// return connectionSource; -// } -// -// /** -// * @param connectionSource The connectionSource to set. -// */ -// public void setConnectionSource(ConnectionSource connectionSource) { -// LogLog.debug("setConnectionSource called for DBAppender"); -// this.connectionSource = connectionSource; -// } -// -// protected void append(LoggingEvent event) { -// Connection connection = null; -// try { -// connection = connectionSource.getConnection(); -// connection.setAutoCommit(false); -// -// PreparedStatement insertStatement; -// if (cnxSupportsGetGeneratedKeys) { -// insertStatement = connection.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS); -// } else { -// insertStatement = connection.prepareStatement(insertSQL); -// } -// -// /* insertStatement.setLong(1, event.getSequenceNumber());*/ -// insertStatement.setLong(1, 0); -// -// insertStatement.setLong(2, event.getTimeStamp()); -// insertStatement.setString(3, event.getRenderedMessage()); -// insertStatement.setString(4, event.getLoggerName()); -// insertStatement.setString(5, event.getLevel().toString()); -// insertStatement.setString(6, event.getNDC()); -// insertStatement.setString(7, event.getThreadName()); -// insertStatement.setShort(8, DBHelper.computeReferenceMask(event)); -// -// LocationInfo li; -// -// if (event.locationInformationExists() || locationInfo) { -// li = event.getLocationInformation(); -// } else { -// li = LocationInfo.NA_LOCATION_INFO; -// } -// -// insertStatement.setString(9, li.getFileName()); -// insertStatement.setString(10, li.getClassName()); -// insertStatement.setString(11, li.getMethodName()); -// insertStatement.setString(12, li.getLineNumber()); -// -// int updateCount = insertStatement.executeUpdate(); -// if (updateCount != 1) { -// LogLog.warn("Failed to insert loggingEvent"); -// } -// -// ResultSet rs = null; -// Statement idStatement = null; -// boolean gotGeneratedKeys = false; -// if (cnxSupportsGetGeneratedKeys) { -// rs = insertStatement.getGeneratedKeys(); -// gotGeneratedKeys = true; -// } -// -// if (!gotGeneratedKeys) { -// insertStatement.close(); -// insertStatement = null; -// -// idStatement = connection.createStatement(); -// idStatement.setMaxRows(1); -// rs = idStatement.executeQuery(sqlDialect.getSelectInsertId()); -// } -// -// // A ResultSet cursor is initially positioned before the first row; the -// // first call to the method next makes the first row the current row -// rs.next(); -// int eventId = rs.getInt(1); -// -// rs.close(); -// -// // we no longer need the insertStatement -// if (insertStatement != null) { -// insertStatement.close(); -// } -// -// if (idStatement != null) { -// idStatement.close(); -// } -// -// Set propertiesKeys = event.getPropertyKeySet(); -// -// if (propertiesKeys.size() > 0) { -// PreparedStatement insertPropertiesStatement = -// connection.prepareStatement(insertPropertiesSQL); -// -// for (Object propertiesKey : propertiesKeys) { -// String key = (String) propertiesKey; -// String value = event.getProperty(key); -// -// //LogLog.info("id " + eventId + ", key " + key + ", value " + value); -// insertPropertiesStatement.setInt(1, eventId); -// insertPropertiesStatement.setString(2, key); -// insertPropertiesStatement.setString(3, value); -// -// if (cnxSupportsBatchUpdates) { -// insertPropertiesStatement.addBatch(); -// } else { -// insertPropertiesStatement.execute(); -// } -// } -// -// if (cnxSupportsBatchUpdates) { -// insertPropertiesStatement.executeBatch(); -// } -// -// insertPropertiesStatement.close(); -// } -// -// String[] strRep = event.getThrowableStrRep(); -// -// if (strRep != null) { -// LogLog.debug("Logging an exception"); -// -// PreparedStatement insertExceptionStatement = -// connection.prepareStatement(insertExceptionSQL); -// -// for (short i = 0; i < strRep.length; i++) { -// insertExceptionStatement.setInt(1, eventId); -// insertExceptionStatement.setShort(2, i); -// insertExceptionStatement.setString(3, strRep[i]); -// if (cnxSupportsBatchUpdates) { -// insertExceptionStatement.addBatch(); -// } else { -// insertExceptionStatement.execute(); -// } -// } -// if (cnxSupportsBatchUpdates) { -// insertExceptionStatement.executeBatch(); -// } -// insertExceptionStatement.close(); -// } -// -// connection.commit(); -// } catch (Throwable sqle) { -// LogLog.error("problem appending event", sqle); -// } finally { -// DBHelper.closeConnection(connection); -// } -// } -// -// public void close() { -// closed = true; -// } -// -// /** -// * Returns value of the <b>LocationInfo </b> property which determines whether -// * caller's location info is written to the database. -// */ -// public boolean getLocationInfo() { -// return locationInfo; -// } -// -// /** -// * If true, the information written to the database will include caller's -// * location information. Due to performance concerns, by default no location -// * information is written to the database. -// */ -// public void setLocationInfo(boolean locationInfo) { -// this.locationInfo = locationInfo; -// } -// -// /** -// * Gets whether appender requires a layout. -// * -// * @return false -// */ -// public boolean requiresLayout() { -// return false; -// } -// -// /** -// * {@inheritDoc} -// */ -// public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { -// if ("connectionSource".equals(element.getNodeName())) { -// Object instance = -// DOMConfigurator.parseElement(element, props, ConnectionSource.class); -// if (instance instanceof ConnectionSource) { -// ConnectionSource source = (ConnectionSource) instance; -// source.activateOptions(); -// setConnectionSource(source); -// } -// return true; -// } -// return false; -// } -//} diff --git a/src/main/java/org/apache/log4j/db/DBHelper.java b/src/main/java/org/apache/log4j/db/DBHelper.java deleted file mode 100644 index 88d17fb..0000000 --- a/src/main/java/org/apache/log4j/db/DBHelper.java +++ /dev/null @@ -1,67 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.spi.LoggingEvent; -// -//import java.sql.Connection; -//import java.sql.SQLException; -//import java.sql.Statement; -//import java.util.Set; -// -///** -// * @author Ceki Gülcü -// */ -//public class DBHelper { -// -// public final static short PROPERTIES_EXIST = 0x01; -// public final static short EXCEPTION_EXISTS = 0x02; -// -// public static short computeReferenceMask(LoggingEvent event) { -// short mask = 0; -// Set propertiesKeys = event.getPropertyKeySet(); -// if (propertiesKeys.size() > 0) { -// mask = PROPERTIES_EXIST; -// } -// String[] strRep = event.getThrowableStrRep(); -// if (strRep != null) { -// mask |= EXCEPTION_EXISTS; -// } -// return mask; -// } -// -// static public void closeConnection(Connection connection) { -// if (connection != null) { -// try { -// connection.close(); -// } catch (SQLException sqle) { -// // static utility classes should not log without an explicit repository -// // reference -// } -// } -// } -// -// public static void closeStatement(Statement statement) { -// if (statement != null) { -// try { -// statement.close(); -// } catch (SQLException sqle) { -// } -// } -// } -//} diff --git a/src/main/java/org/apache/log4j/db/DBReceiver.java b/src/main/java/org/apache/log4j/db/DBReceiver.java deleted file mode 100644 index e40e808..0000000 --- a/src/main/java/org/apache/log4j/db/DBReceiver.java +++ /dev/null @@ -1,139 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.plugins.Pauseable; -//import org.apache.log4j.plugins.Receiver; -//import org.apache.log4j.scheduler.Scheduler; -//import org.apache.log4j.spi.LoggerRepositoryEx; -//import org.apache.log4j.xml.DOMConfigurator; -//import org.apache.log4j.xml.UnrecognizedElementHandler; -//import org.w3c.dom.Element; -// -//import java.util.Properties; -// -///** -// * @author Scott Deboy <[email protected]> -// * @author Ceki Gülcü -// */ -//public class DBReceiver extends Receiver implements Pauseable, UnrecognizedElementHandler { -// /** -// * By default we refresh data every 1000 milliseconds. -// * -// * @see #setRefreshMillis -// */ -// static int DEFAULT_REFRESH_MILLIS = 1000; -// ConnectionSource connectionSource; -// int refreshMillis = DEFAULT_REFRESH_MILLIS; -// DBReceiverJob receiverJob; -// boolean paused = false; -// -// public void activateOptions() { -// -// if (connectionSource == null) { -// throw new IllegalStateException( -// "DBAppender cannot function without a connection source"); -// } -// -// receiverJob = new DBReceiverJob(this); -// receiverJob.setLoggerRepository(repository); -// -// if (this.repository == null) { -// throw new IllegalStateException( -// "DBAppender cannot function without a reference to its owning repository"); -// } -// -// if (repository instanceof LoggerRepositoryEx) { -// Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); -// -// scheduler.schedule( -// receiverJob, System.currentTimeMillis() + 500, refreshMillis); -// } -// -// } -// -// public void setRefreshMillis(int refreshMillis) { -// this.refreshMillis = refreshMillis; -// } -// -// public int getRefreshMillis() { -// return refreshMillis; -// } -// -// -// /** -// * @return Returns the connectionSource. -// */ -// public ConnectionSource getConnectionSource() { -// return connectionSource; -// } -// -// -// /** -// * @param connectionSource The connectionSource to set. -// */ -// public void setConnectionSource(ConnectionSource connectionSource) { -// this.connectionSource = connectionSource; -// } -// -// -// /* (non-Javadoc) -// * @see org.apache.log4j.plugins.Plugin#shutdown() -// */ -// public void shutdown() { -// getLogger().info("removing receiverJob from the Scheduler."); -// -// if (this.repository instanceof LoggerRepositoryEx) { -// Scheduler scheduler = ((LoggerRepositoryEx) repository).getScheduler(); -// scheduler.delete(receiverJob); -// } -// } -// -// -// /* (non-Javadoc) -// * @see org.apache.log4j.plugins.Pauseable#setPaused(boolean) -// */ -// public void setPaused(boolean paused) { -// this.paused = paused; -// } -// -// /* (non-Javadoc) -// * @see org.apache.log4j.plugins.Pauseable#isPaused() -// */ -// public boolean isPaused() { -// return paused; -// } -// -// /** -// * {@inheritDoc} -// */ -// public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { -// if ("connectionSource".equals(element.getNodeName())) { -// Object instance = -// DOMConfigurator.parseElement(element, props, ConnectionSource.class); -// if (instance instanceof ConnectionSource) { -// ConnectionSource source = (ConnectionSource) instance; -// source.activateOptions(); -// setConnectionSource(source); -// } -// return true; -// } -// return false; -// } -// -//} diff --git a/src/main/java/org/apache/log4j/db/DBReceiverJob.java b/src/main/java/org/apache/log4j/db/DBReceiverJob.java deleted file mode 100644 index 45233fc..0000000 --- a/src/main/java/org/apache/log4j/db/DBReceiverJob.java +++ /dev/null @@ -1,224 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import org.apache.log4j.Level; -//import org.apache.log4j.Logger; -//import org.apache.log4j.scheduler.Job; -//import org.apache.log4j.spi.ComponentBase; -//import org.apache.log4j.spi.LocationInfo; -//import org.apache.log4j.spi.LoggingEvent; -//import org.apache.log4j.spi.ThrowableInformation; -// -//import java.sql.Connection; -//import java.sql.PreparedStatement; -//import java.sql.ResultSet; -//import java.sql.SQLException; -//import java.util.Hashtable; -//import java.util.Vector; -// -///** -// * Actual retrieval of data is made by the instance of DBReceiverJob associated -// * with DBReceiver. -// * -// * @author Ceki Gülcü -// */ -//class DBReceiverJob extends ComponentBase implements Job { -// -// String sqlException = "SELECT trace_line FROM logging_event_exception where event_id=? ORDER by i ASC"; -// String sqlProperties = "SELECT mapped_key, mapped_value FROM logging_event_property WHERE event_id=?"; -// String sqlSelect = -// "SELECT " + -// "sequence_number, timestamp, rendered_message, logger_name, " + -// "level_string, ndc, thread_name, reference_flag, " + -// "caller_filename, caller_class, caller_method, caller_line, " + -// "event_id " + -// "FROM logging_event " + -// "WHERE event_id > ? ORDER BY event_id ASC"; -// -// -// long lastId = Short.MIN_VALUE; -// -// DBReceiver parentDBReceiver; -// -// DBReceiverJob(DBReceiver parent) { -// parentDBReceiver = parent; -// } -// -// public void execute() { -// getLogger().debug("DBReceiverJob.execute() called"); -// -// Connection connection = null; -// -// try { -// connection = parentDBReceiver.connectionSource.getConnection(); -// PreparedStatement statement = connection.prepareStatement(sqlSelect); -// statement.setLong(1, lastId); -// ResultSet rs = statement.executeQuery(); -// //rs.beforeFirst(); -// -// while (rs.next()) { -// Logger logger; -// long timeStamp; -// String level; -// String threadName; -// Object message; -// String ndc; -// String className; -// String methodName; -// String fileName; -// String lineNumber; -// Hashtable properties = new Hashtable(); -// -// -// //event.setSequenceNumber(rs.getLong(1)); -// timeStamp = rs.getLong(2); -// message = rs.getString(3); -// logger = Logger.getLogger(rs.getString(4)); -// level = rs.getString(5); -// Level levelImpl = Level.toLevel(level.trim()); -// -// ndc = rs.getString(6); -// threadName = rs.getString(7); -// -// short mask = rs.getShort(8); -// -// fileName = rs.getString(9); -// className = rs.getString(10); -// methodName = rs.getString(11); -// lineNumber = rs.getString(12).trim(); -// -// LocationInfo locationInfo; -// if (fileName.equals(LocationInfo.NA)) { -// locationInfo = LocationInfo.NA_LOCATION_INFO; -// } else { -// locationInfo = new LocationInfo(fileName, className, -// methodName, lineNumber); -// } -// -// long id = rs.getLong(13); -// //LogLog.info("Received event with id=" + id); -// lastId = id; -// -// ThrowableInformation throwableInfo = null; -// if ((mask & DBHelper.EXCEPTION_EXISTS) != 0) { -// throwableInfo = getException(connection, id); -// } -// -// LoggingEvent event = new LoggingEvent(logger.getName(), -// logger, timeStamp, levelImpl, message, -// threadName, -// throwableInfo, -// ndc, -// locationInfo, -// properties); -// -// -// // Scott asked for this info to be -// event.setProperty("log4jid", Long.toString(id)); -// -// if ((mask & DBHelper.PROPERTIES_EXIST) != 0) { -// getProperties(connection, id, event); -// } -// -// -// if (!parentDBReceiver.isPaused()) { -// parentDBReceiver.doPost(event); -// } -// } // while -// statement.close(); -// } catch (SQLException sqle) { -// getLogger().error("Problem receiving events", sqle); -// } finally { -// closeConnection(connection); -// } -// } -// -// void closeConnection(Connection connection) { -// if (connection != null) { -// try { -// //LogLog.warn("closing the connection. ", new Exception("x")); -// connection.close(); -// } catch (SQLException sqle) { -// // nothing we can do here -// } -// } -// } -// -// /** -// * Retrieve the event properties from the logging_event_property table. -// * -// * @param connection -// * @param id -// * @param event -// * @throws SQLException -// */ -// void getProperties(Connection connection, long id, LoggingEvent event) -// throws SQLException { -// -// try (PreparedStatement statement = connection.prepareStatement(sqlProperties)) { -// statement.setLong(1, id); -// ResultSet rs = statement.executeQuery(); -// -// while (rs.next()) { -// String key = rs.getString(1); -// String value = rs.getString(2); -// event.setProperty(key, value); -// } -// } -// } -// -// /** -// * Retrieve the exception string representation from the -// * logging_event_exception table. -// * -// * @param connection -// * @param id -// * @throws SQLException -// */ -// ThrowableInformation getException(Connection connection, long id) -// throws SQLException { -// -// PreparedStatement statement = null; -// -// try { -// statement = connection.prepareStatement(sqlException); -// statement.setLong(1, id); -// ResultSet rs = statement.executeQuery(); -// -// Vector<String> v = new Vector<>(); -// -// while (rs.next()) { -// //int i = rs.getShort(1); -// v.add(rs.getString(1)); -// } -// -// int len = v.size(); -// String[] strRep = new String[len]; -// for (int i = 0; i < len; i++) { -// strRep[i] = v.get(i); -// } -// // we've filled strRep, we now attach it to the event -// return new ThrowableInformation(strRep); -// } finally { -// if (statement != null) { -// statement.close(); -// } -// } -// } -//} diff --git a/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java b/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java deleted file mode 100644 index e5e1ebb..0000000 --- a/src/main/java/org/apache/log4j/db/DataSourceConnectionSource.java +++ /dev/null @@ -1,105 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -// -//import org.apache.log4j.xml.DOMConfigurator; -//import org.apache.log4j.xml.UnrecognizedElementHandler; -//import org.w3c.dom.Element; -// -//import javax.sql.DataSource; -//import java.sql.Connection; -//import java.sql.SQLException; -//import java.util.Properties; -// -// -///** -// * The DataSourceConnectionSource is an implementation of {@link ConnectionSource} -// * that obtains the Connection in the recommended JDBC manner based on -// * a {@link javax.sql.DataSource DataSource}. -// * <p> -// * -// * @author Ray DeCampo -// * @author Ceki Gülcü -// */ -//public class DataSourceConnectionSource extends ConnectionSourceSkeleton -// implements UnrecognizedElementHandler { -// -// private DataSource dataSource; -// -// -// public void activateOptions() { -// //LogLog.debug("**********DataSourceConnectionSource.activateOptions called"); -// if (dataSource == null) { -// getLogger().warn("WARNING: No data source specified"); -// } else { -// Connection connection = null; -// try { -// connection = getConnection(); -// } catch (SQLException se) { -// getLogger().warn("Could not get a connection to discover the dialect to use.", se); -// } -// if (connection != null) { -// discoverConnnectionProperties(); -// } -// if (!supportsGetGeneratedKeys() && getSQLDialectCode() == ConnectionSource.UNKNOWN_DIALECT) { -// getLogger().warn("Connection does not support GetGeneratedKey method and could not discover the dialect."); -// } -// } -// } -// -// /** -// * @see org.apache.log4j.db.ConnectionSource#getConnection() -// */ -// public Connection getConnection() throws SQLException { -// if (dataSource == null) { -// getLogger().error("WARNING: No data source specified"); -// return null; -// } -// -// if (getUser() == null) { -// return dataSource.getConnection(); -// } else { -// return dataSource.getConnection(getUser(), getPassword()); -// } -// } -// -// public DataSource getDataSource() { -// return dataSource; -// } -// -// public void setDataSource(DataSource dataSource) { -// this.dataSource = dataSource; -// } -// -// /** -// * {@inheritDoc} -// */ -// public boolean parseUnrecognizedElement(Element element, Properties props) throws Exception { -// if ("dataSource".equals(element.getNodeName())) { -// Object instance = -// DOMConfigurator.parseElement(element, props, DataSource.class); -// if (instance instanceof DataSource) { -// setDataSource((DataSource) instance); -// } -// return true; -// } -// return false; -// } -// -//} diff --git a/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java b/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java deleted file mode 100644 index d389632..0000000 --- a/src/main/java/org/apache/log4j/db/DriverManagerConnectionSource.java +++ /dev/null @@ -1,137 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db; -// -//import java.sql.Connection; -//import java.sql.DriverManager; -//import java.sql.SQLException; -// -// -///** -// * The DriverManagerConnectionSource is an implementation of {@link ConnectionSource} -// * that obtains the Connection in the traditional JDBC manner based on the -// * connection URL. -// * <p> -// * Note that this class will establish a new Connection for each call to -// * {@link #getConnection()}. It is recommended that you either use a JDBC -// * driver that natively supported Connection pooling or that you create -// * your own implementation of {@link ConnectionSource} that taps into whatever -// * pooling mechanism you are already using. (If you have access to a JNDI -// * implementation that supports {@link javax.sql.DataSource}s, e.g. within -// * a J2EE application server, see {@link JNDIConnectionSource}). See -// * <a href="#dbcp">below</a> for a configuration example that uses the -// * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> -// * package from Apache. -// * <p> -// * Sample configuration:<br> -// * <pre> -// * <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource"> -// * <param name="driver" value="com.mysql.jdbc.Driver" /> -// * <param name="url" value="jdbc:mysql://localhost:3306/mydb" /> -// * <param name="username" value="myUser" /> -// * <param name="password" value="myPassword" /> -// * </connectionSource> -// * </pre> -// * <p> -// * <a name="dbcp">If</a> you do not have another connection pooling mechanism -// * built into your application, you can use the -// * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> -// * package from Apache:<br> -// * <pre> -// * <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource"> -// * <param name="driver" value="org.apache.commons.dbcp.PoolingDriver" /> -// * <param name="url" value="jdbc:apache:commons:dbcp:/myPoolingDriver" /> -// * </connectionSource> -// * </pre> -// * Then the configuration information for the commons-dbcp package goes into -// * the file myPoolingDriver.jocl and is placed in the classpath. See the -// * <a href="http://jakarta.apache.org/commons/dbcp/index.html">commons-dbcp</a> -// * documentation for details. -// * -// * @author <a href="mailto:[email protected]">Ray DeCampo</a> -// */ -//public class DriverManagerConnectionSource extends ConnectionSourceSkeleton { -// private String driverClass = null; -// private String url = null; -// -// public void activateOptions() { -// try { -// if (driverClass != null) { -// Class.forName(driverClass); -// discoverConnnectionProperties(); -// } else { -// getLogger().error( -// "WARNING: No JDBC driver specified for log4j DriverManagerConnectionSource."); -// } -// } catch (final ClassNotFoundException cnfe) { -// getLogger().error("Could not load JDBC driver class: " + driverClass, cnfe); -// } -// } -// -// -// /** -// * @see org.apache.log4j.db.ConnectionSource#getConnection() -// */ -// public Connection getConnection() throws SQLException { -// if (getUser() == null) { -// return DriverManager.getConnection(url); -// } else { -// return DriverManager.getConnection(url, getUser(), getPassword()); -// } -// } -// -// -// /** -// * Returns the url. -// * -// * @return String -// */ -// public String getUrl() { -// return url; -// } -// -// -// /** -// * Sets the url. -// * -// * @param url The url to set -// */ -// public void setUrl(String url) { -// this.url = url; -// } -// -// -// /** -// * Returns the name of the driver class. -// * -// * @return String -// */ -// public String getDriverClass() { -// return driverClass; -// } -// -// -// /** -// * Sets the driver class. -// * -// * @param driverClass The driver class to set -// */ -// public void setDriverClass(String driverClass) { -// this.driverClass = driverClass; -// } -//} diff --git a/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java b/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java deleted file mode 100644 index f7f2d6a..0000000 --- a/src/main/java/org/apache/log4j/db/JNDIConnectionSource.java +++ /dev/null @@ -1,144 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -//package org.apache.log4j.db; -// -//import javax.naming.Context; -//import javax.naming.InitialContext; -//import javax.naming.NamingException; -//import javax.sql.DataSource; -//import java.sql.Connection; -//import java.sql.SQLException; -// -//// PortableRemoteObject was introduced in JDK 1.3. We won't use it. -//// import javax.rmi.PortableRemoteObject; -// -// -///** -// * The {@code JNDIConnectionSource} is an implementation of -// * {@link ConnectionSource} that obtains a {@link javax.sql.DataSource} from a -// * JNDI provider and uses it to obtain a {@link java.sql.Connection}. It is -// * primarily designed to be used inside of J2EE application servers or -// * application server clients, assuming the application server supports remote -// * access of {@link javax.sql.DataSource}s. In this way one can take -// * advantage of connection pooling and whatever other goodies the application -// * server provides. -// * <p> -// * Sample configuration:<br> -// * <pre> -// * <connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> -// * <param name="jndiLocation" value="jdbc/MySQLDS" /> -// * </connectionSource> -// * </pre> -// * <p> -// * Sample configuration (with username and password):<br> -// * <pre> -// * <connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> -// * <param name="jndiLocation" value="jdbc/MySQLDS" /> -// * <param name="username" value="myUser" /> -// * <param name="password" value="myPassword" /> -// * </connectionSource> -// * </pre> -// * <p> -// * Note that this class will obtain an {@link javax.naming.InitialContext} -// * using the no-argument constructor. This will usually work when executing -// * within a J2EE environment. When outside the J2EE environment, make sure -// * that you provide a jndi.properties file as described by your JNDI -// * provider's documentation. -// * -// * @author <a href="mailto:[email protected]">Ray DeCampo</a> -// */ -//public class JNDIConnectionSource -// extends ConnectionSourceSkeleton { -// private String jndiLocation = null; -// private DataSource dataSource = null; -// -// /** -// * @see org.apache.log4j.spi.OptionHandler#activateOptions() -// */ -// public void activateOptions() { -// if (jndiLocation == null) { -// getLogger().error("No JNDI location specified for JNDIConnectionSource."); -// } -// -// discoverConnnectionProperties(); -// -// } -// -// /** -// * @see org.apache.log4j.db.ConnectionSource#getConnection() -// */ -// public Connection getConnection() -// throws SQLException { -// Connection conn; -// try { -// -// if (dataSource == null) { -// dataSource = lookupDataSource(); -// } -// if (getUser() == null) { -// conn = dataSource.getConnection(); -// } else { -// conn = dataSource.getConnection(getUser(), getPassword()); -// } -// } catch (final NamingException ne) { -// getLogger().error("Error while getting data source", ne); -// throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); -// } catch (final ClassCastException cce) { -// getLogger().error("ClassCastException while looking up DataSource.", cce); -// throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); -// } -// -// return conn; -// } -// -// /** -// * Returns the jndiLocation. -// * -// * @return String -// */ -// public String getJndiLocation() { -// return jndiLocation; -// } -// -// -// /** -// * Sets the jndiLocation. -// * -// * @param jndiLocation The jndiLocation to set -// */ -// public void setJndiLocation(String jndiLocation) { -// this.jndiLocation = jndiLocation; -// } -// -// -// private DataSource lookupDataSource() -// throws NamingException, SQLException { -// DataSource ds; -// Context ctx = new InitialContext(); -// Object obj = ctx.lookup(jndiLocation); -// -// // PortableRemoteObject was introduced in JDK 1.3. We won't use it. -// //ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); -// ds = (DataSource) obj; -// -// if (ds == null) { -// throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); -// } else { -// return ds; -// } -// } -//} diff --git a/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java b/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java deleted file mode 100644 index efddad5..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/HSQLDBDialect.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.db.dialect; - -/** - * The HSQLDB dialect. - * - * @author <a href="http://www.qos.ch/log4j/">Ceki Gülcü</a> - */ -public class HSQLDBDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "CALL IDENTITY()"; - - public String getSelectInsertId() { - return SELECT_CURRVAL; - } -} diff --git a/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java deleted file mode 100644 index 32368d6..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/MsSQLDialect.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.db.dialect; - -/** - * The MS SQL Server dialect is untested. - * <p> - * Note that the dialect is not needed if your JDBC driver supports - * the getGeneratedKeys method introduced in JDBC 3.0 specification. - * - * @author James Stauffer - */ -public class MsSQLDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT @@identity id"; - - public String getSelectInsertId() { - return SELECT_CURRVAL; - } -} diff --git a/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java deleted file mode 100644 index 993df83..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/MySQLDialect.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.db.dialect; - -/** - * @author Ceki - */ -public class MySQLDialect implements SQLDialect { - public static final String SELECT_LAST_INSERT_ID = "SELECT LAST_INSERT_ID()"; - - public String getSelectInsertId() { - return SELECT_LAST_INSERT_ID; - } -} diff --git a/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java b/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java deleted file mode 100644 index cba2507..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/OracleDialect.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.db.dialect; - -/** - * The Oracle dialect. Tested successfully on Oracle9i Release 9.2.0.3.0 by - * James Stauffer. - * - * @author Ceki Gülcü - */ -public class OracleDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT logging_event_id_seq.currval from dual"; - - public String getSelectInsertId() { - return SELECT_CURRVAL; - } - -} diff --git a/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java deleted file mode 100644 index 8f5d4c9..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/PostgreSQLDialect.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.db.dialect; - - -/** - * @author ceki - * <p> - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public class PostgreSQLDialect - implements SQLDialect { - public static final String SELECT_CURRVAL = "SELECT currval('logging_event_id_seq')"; - - public String getSelectInsertId() { - return SELECT_CURRVAL; - } -} diff --git a/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java b/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java deleted file mode 100644 index 538b74d..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/SQLDialect.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.log4j.db.dialect; - -/** - * @author ceki - */ -public interface SQLDialect { - - String getSelectInsertId(); - -} diff --git a/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java b/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java deleted file mode 100644 index 38bcabb..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/SybaseDialect.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.log4j.db.dialect; - -/** - * The Sybase dialect. - */ -public class SybaseDialect implements SQLDialect { - public static final String SELECT_CURRVAL = "select @@identity"; - - public String getSelectInsertId() { - return SELECT_CURRVAL; - } -} diff --git a/src/main/java/org/apache/log4j/db/dialect/Util.java b/src/main/java/org/apache/log4j/db/dialect/Util.java deleted file mode 100644 index a79b7d8..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/Util.java +++ /dev/null @@ -1,119 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one or more -// * contributor license agreements. See the NOTICE file distributed with -// * this work for additional information regarding copyright ownership. -// * The ASF licenses this file to You under the Apache License, Version 2.0 -// * (the "License"); you may not use this file except in compliance with -// * the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package org.apache.log4j.db.dialect; -// -//import org.apache.log4j.db.ConnectionSource; -// -//import java.sql.DatabaseMetaData; -//import java.sql.SQLException; -// -// -///** -// * @author Ceki Gulcu -// */ -//public class Util { -// private static final String POSTGRES_PART = "postgresql"; -// private static final String MYSQL_PART = "mysql"; -// private static final String ORACLE_PART = "oracle"; -// //private static final String MSSQL_PART = "mssqlserver4"; -// private static final String MSSQL_PART = "microsoft"; -// private static final String HSQL_PART = "hsql"; -// -// public static int discoverSQLDialect(DatabaseMetaData meta) { -// int dialectCode = 0; -// -// try { -// -// String dbName = meta.getDatabaseProductName().toLowerCase(); -// -// if (dbName.contains(POSTGRES_PART)) { -// return ConnectionSource.POSTGRES_DIALECT; -// } else if (dbName.contains(MYSQL_PART)) { -// return ConnectionSource.MYSQL_DIALECT; -// } else if (dbName.contains(ORACLE_PART)) { -// return ConnectionSource.ORACLE_DIALECT; -// } else if (dbName.contains(MSSQL_PART)) { -// return ConnectionSource.MSSQL_DIALECT; -// } else if (dbName.contains(HSQL_PART)) { -// return ConnectionSource.HSQL_DIALECT; -// } else { -// return ConnectionSource.UNKNOWN_DIALECT; -// } -// } catch (SQLException sqle) { -// // we can't do much here -// } -// -// return dialectCode; -// } -// -// public static SQLDialect getDialectFromCode(int dialectCode) { -// SQLDialect sqlDialect = null; -// -// switch (dialectCode) { -// case ConnectionSource.POSTGRES_DIALECT: -// sqlDialect = new PostgreSQLDialect(); -// -// break; -// case ConnectionSource.MYSQL_DIALECT: -// sqlDialect = new MySQLDialect(); -// -// break; -// case ConnectionSource.ORACLE_DIALECT: -// sqlDialect = new OracleDialect(); -// -// break; -// case ConnectionSource.MSSQL_DIALECT: -// sqlDialect = new MsSQLDialect(); -// -// break; -// case ConnectionSource.HSQL_DIALECT: -// sqlDialect = new HSQLDBDialect(); -// -// break; -// } -// return sqlDialect; -// } -// -// /** -// * This method handles cases where the -// * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the -// * JDBC driver implementation. -// */ -// public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { -// try { -// return meta.supportsGetGeneratedKeys(); -// } catch (Throwable e) { -//// getLogger().info("Could not call supportsGetGeneratedKeys method. This may be recoverable"); -// return false; -// } -// } -// -// /** -// * This method handles cases where the -// * {@link DatabaseMetaData#supportsBatchUpdates} method is missing in the -// * JDBC driver implementation. -// */ -// public boolean supportsBatchUpdates(DatabaseMetaData meta) { -// try { -// return meta.supportsBatchUpdates(); -// } catch (Throwable e) { -//// getLogger().info("Missing DatabaseMetaData.supportsBatchUpdates method."); -// return false; -// } -// } -//} diff --git a/src/main/java/org/apache/log4j/db/dialect/db2.sql b/src/main/java/org/apache/log4j/db/dialect/db2.sql deleted file mode 100644 index 47d2164..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/db2.sql +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# This SQL script creates the required tables by org.apache.log4j.db.DBAppender and -# org.apache.log4j.db.DBReceiver. -# -# It is intended for IBM DB2 databases. -# -# WARNING WARNING WARNING WARNING -# ================================= -# This SQL script has not been tested on an actual DB2 -# instance. It may contain errors or even invalid SQL -# statements. - -DROP TABLE logging_event_property; -DROP TABLE logging_event_exception; -DROP TABLE logging_event; - -CREATE TABLE logging_event - ( - sequence_number BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - rendered_message VARCHAR(4000) NOT NULL, - logger_name VARCHAR(254) NOT NULL, - level_string VARCHAR(254) NOT NULL, - ndc VARCHAR(4000), - thread_name VARCHAR(254), - reference_flag SMALLINT, - caller_filename VARCHAR(254) NOT NULL, - caller_class VARCHAR(254) NOT NULL, - caller_method VARCHAR(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1) - ); - -CREATE TABLE logging_event_property - ( - event_id INTEGER NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value VARCHAR(1024), - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - -CREATE TABLE logging_event_exception - ( - event_id INTEGER NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); diff --git a/src/main/java/org/apache/log4j/db/dialect/db2l.sql b/src/main/java/org/apache/log4j/db/dialect/db2l.sql deleted file mode 100644 index 0f91315..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/db2l.sql +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# This SQL script creates the required tables by org.apache.log4j.db.DBAppender and -# org.apache.log4j.db.DBReceiver. -# -# It is intended for PostgreSQL databases. - -DROP TABLE logging_event_property; -DROP TABLE logging_event_exception; -DROP TABLE logging_event; - - -CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START 1; - - -CREATE TABLE logging_event - ( - sequence_number BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - rendered_message TEXT NOT NULL, - logger_name VARCHAR(254) NOT NULL, - level_string VARCHAR(254) NOT NULL, - ndc TEXT, - thread_name VARCHAR(254), - reference_flag SMALLINT, - caller_filename VARCHAR(254) NOT NULL, - caller_class VARCHAR(254) NOT NULL, - caller_method VARCHAR(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id INT IDENTITY GENERATED ALWAYS PRIMARY KEY - ); - -CREATE TABLE logging_event_property - ( - event_id INT NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value VARCHAR(1024), - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - -CREATE TABLE logging_event_exception - ( - event_id INT NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); diff --git a/src/main/java/org/apache/log4j/db/dialect/hsqldb.sql b/src/main/java/org/apache/log4j/db/dialect/hsqldb.sql deleted file mode 100644 index 50f8f78..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/hsqldb.sql +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// This SQL script creates the required tables by -// org.apache.log4j.db.DBAppender and org.apache.log4j.db.DBReceiver. -// -// It is intended for HSQLDB. -// - -DROP TABLE logging_event_exception IF EXISTS; -DROP TABLE logging_event_property IF EXISTS; -DROP TABLE logging_event IF EXISTS; - - -CREATE TABLE logging_event - ( - sequence_number BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - rendered_message LONGVARCHAR NOT NULL, - logger_name VARCHAR NOT NULL, - level_string VARCHAR NOT NULL, - ndc LONGVARCHAR, - thread_name VARCHAR, - reference_flag SMALLINT, - caller_filename VARCHAR, - caller_class VARCHAR, - caller_method VARCHAR, - caller_line CHAR(4), - event_id INT NOT NULL IDENTITY - ); - - -CREATE TABLE logging_event_property - ( - event_id INT NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value LONGVARCHAR, - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - -CREATE TABLE logging_event_exception - ( - event_id INT NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); diff --git a/src/main/java/org/apache/log4j/db/dialect/mssql.sql b/src/main/java/org/apache/log4j/db/dialect/mssql.sql deleted file mode 100644 index d87e0a0..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/mssql.sql +++ /dev/null @@ -1,61 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one or more --- contributor license agreements. See the NOTICE file distributed with --- this work for additional information regarding copyright ownership. --- The ASF licenses this file to You under the Apache License, Version 2.0 --- (the "License"); you may not use this file except in compliance with --- the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- --- This SQL script creates the required tables by org.apache.log4j.db.DBAppender and --- org.apache.log4j.db.DBReceiver. --- --- It is intended for MS SQL Server databases. This has been tested with version 7.0. - -DROP TABLE logging_event_property -DROP TABLE logging_event_exception -DROP TABLE logging_event - -CREATE TABLE logging_event - ( - sequence_number DECIMAL(20) NOT NULL, - timestamp DECIMAL(20) NOT NULL, - rendered_message VARCHAR(4000) NOT NULL, - logger_name VARCHAR(254) NOT NULL, - level_string VARCHAR(254) NOT NULL, - ndc VARCHAR(4000), - thread_name VARCHAR(254), - reference_flag SMALLINT, - caller_filename VARCHAR(254) NOT NULL, - caller_class VARCHAR(254) NOT NULL, - caller_method VARCHAR(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id INT NOT NULL identity, - PRIMARY KEY(event_id) - ) - -CREATE TABLE logging_event_property - ( - event_id INT NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value VARCHAR(1024), - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ) - -CREATE TABLE logging_event_exception - ( - event_id INT NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ) - diff --git a/src/main/java/org/apache/log4j/db/dialect/mysql.sql b/src/main/java/org/apache/log4j/db/dialect/mysql.sql deleted file mode 100644 index e3a2be1..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/mysql.sql +++ /dev/null @@ -1,71 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# -# This SQL script creates the required tables by org.apache.log4j.db.DBAppender and -# org.apache.log4j.db.DBReceiver. -# -# It is intended for MySQL databases. It has been tested on MySQL 4.1.1 with -# INNODB tables. - - -BEGIN; -DROP TABLE IF EXISTS logging_event_property; -DROP TABLE IF EXISTS logging_event_exception; -DROP TABLE IF EXISTS logging_event; -COMMIT; - - -BEGIN; -CREATE TABLE logging_event - ( - sequence_number BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - rendered_message TEXT NOT NULL, - logger_name VARCHAR(254) NOT NULL, - level_string VARCHAR(254) NOT NULL, - ndc TEXT, - thread_name VARCHAR(254), - reference_flag SMALLINT, - caller_filename VARCHAR(254) NOT NULL, - caller_class VARCHAR(254) NOT NULL, - caller_method VARCHAR(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY - ); -COMMIT; - -BEGIN; -CREATE TABLE logging_event_property - ( - event_id INT NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value TEXT, - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); -COMMIT; - -BEGIN; -CREATE TABLE logging_event_exception - ( - event_id INT NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); -COMMIT; diff --git a/src/main/java/org/apache/log4j/db/dialect/oracle.sql b/src/main/java/org/apache/log4j/db/dialect/oracle.sql deleted file mode 100644 index 84bf9e5..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/oracle.sql +++ /dev/null @@ -1,77 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one or more --- contributor license agreements. See the NOTICE file distributed with --- this work for additional information regarding copyright ownership. --- The ASF licenses this file to You under the Apache License, Version 2.0 --- (the "License"); you may not use this file except in compliance with --- the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- --- This SQL script creates the required tables by org.apache.log4j.db.DBAppender and --- org.apache.log4j.db.DBReceiver. --- --- It is intended for Oracle databases. - --- Tested successfully on Oracle9i Release 9.2.0.3.0 by James Stauffer --- Tested successfully on Oracle9i Release by Elias Ross - --- The following lines are useful in cleaning any previous tables - ---drop TRIGGER logging_event_id_seq_trig; ---drop SEQUENCE logging_event_id_seq; ---drop table logging_event_property; ---drop table logging_event_exception; ---drop table logging_event; - -CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START WITH 1; - -CREATE TABLE logging_event - ( - sequence_number NUMBER(20) NOT NULL, - timestamp NUMBER(20) NOT NULL, - rendered_message VARCHAR2(4000) NOT NULL, - logger_name VARCHAR2(254) NOT NULL, - level_string VARCHAR2(254) NOT NULL, - ndc VARCHAR2(4000), - thread_name VARCHAR2(254), - reference_flag NUMBER(5), - caller_filename VARCHAR2(254) NOT NULL, - caller_class VARCHAR2(254) NOT NULL, - caller_method VARCHAR2(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id NUMBER(10) PRIMARY KEY - ); - -CREATE OR REPLACE TRIGGER logging_event_id_seq_trig -BEFORE INSERT ON logging_event -FOR EACH ROW -BEGIN - SELECT logging_event_id_seq.nextval - INTO :new.sequence_number FROM dual; -END; - -CREATE TABLE logging_event_property - ( - event_id NUMBER(10) NOT NULL, - mapped_key VARCHAR2(254) NOT NULL, - mapped_value VARCHAR2(1024), - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - -CREATE TABLE logging_event_exception - ( - event_id NUMBER(10) NOT NULL, - i NUMBER(5) NOT NULL, - trace_line VARCHAR2(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - diff --git a/src/main/java/org/apache/log4j/db/dialect/postgresql.sql b/src/main/java/org/apache/log4j/db/dialect/postgresql.sql deleted file mode 100644 index c38757b..0000000 --- a/src/main/java/org/apache/log4j/db/dialect/postgresql.sql +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -## This SQL script creates the required tables by org.apache.log4j.db.DBAppender and -# org.apache.log4j.db.DBReceiver. -# -# It is intended for PostgreSQL databases. - -DROP TABLE logging_event_property; -DROP TABLE logging_event_exception; -DROP SEQUENCE logging_event_id_seq; -DROP TABLE logging_event; - - -CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START 1; - - -CREATE TABLE logging_event - ( - sequence_number BIGINT NOT NULL, - timestamp BIGINT NOT NULL, - rendered_message TEXT NOT NULL, - logger_name VARCHAR(254) NOT NULL, - level_string VARCHAR(254) NOT NULL, - ndc TEXT, - thread_name VARCHAR(254), - reference_flag SMALLINT, - caller_filename VARCHAR(254) NOT NULL, - caller_class VARCHAR(254) NOT NULL, - caller_method VARCHAR(254) NOT NULL, - caller_line CHAR(4) NOT NULL, - event_id INT DEFAULT nextval('logging_event_id_seq') PRIMARY KEY - ); - -CREATE TABLE logging_event_property - ( - event_id INT NOT NULL, - mapped_key VARCHAR(254) NOT NULL, - mapped_value VARCHAR(1024), - PRIMARY KEY(event_id, mapped_key), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); - -CREATE TABLE logging_event_exception - ( - event_id INT NOT NULL, - i SMALLINT NOT NULL, - trace_line VARCHAR(254) NOT NULL, - PRIMARY KEY(event_id, i), - FOREIGN KEY (event_id) REFERENCES logging_event(event_id) - ); diff --git a/src/main/java/org/apache/log4j/db/package-info.java b/src/main/java/org/apache/log4j/db/package-info.java deleted file mode 100644 index 9e40623..0000000 --- a/src/main/java/org/apache/log4j/db/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Provides means to append logging events into various databases. The persisted data can be later read back using {@link org.apache.log4j.db.DBReceiver}. - * <p> - * Most popular database systems, such as PostgreSQL, MySQL, Oracle, DB2 and MsSQL are supported. - * </p> - * <p> - * Just as importantly, the way for obtaining JDBC connections is pluggable. Connections can be obtained through the traditional way of DriverManager, or - * alternatively as a DataSource. A DataSource can be instantiated directly or it can obtained through JNDI. - * </p> - */ -package org.apache.log4j.db;
