You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ce...@apache.org on 2004/06/04 00:48:17 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/db ConnectionSource.java DBReceiverJob.java DataSourceConnectionSource.java DBAppender.java ConnectionSourceSkeleton.java
ceki 2004/06/03 15:48:17
Modified: src/java/org/apache/log4j/db/dialect HSQLDBDialect.java
Util.java hsqldb.sql
src/java/org/apache/log4j/db ConnectionSource.java
DBReceiverJob.java DataSourceConnectionSource.java
DBAppender.java ConnectionSourceSkeleton.java
Log:
Added support HSQL. It actually works too!
Successfully supporting HSQL means that we should be able to support
databases with older JDBC drivers as well.
Revision Changes Path
1.2 +1 -6 logging-log4j/src/java/org/apache/log4j/db/dialect/HSQLDBDialect.java
Index: HSQLDBDialect.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/dialect/HSQLDBDialect.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HSQLDBDialect.java 20 May 2004 15:38:00 -0000 1.1
+++ HSQLDBDialect.java 3 Jun 2004 22:48:17 -0000 1.2
@@ -17,13 +17,8 @@
package org.apache.log4j.db.dialect;
/**
- * <b>DBAppender DOES NOT WORK WITH HSQLDB.</b>
- *
* The HSQLDB dialect.
- *
- * <b>WARNING</b>
- * IT IS ESTABLISHED THAT DBAppender DOES NOT WORK WITH HSQLDB.
- *
+ *
* @author Ceki Gulcu
*/
public class HSQLDBDialect implements SQLDialect {
1.4 +5 -2 logging-log4j/src/java/org/apache/log4j/db/dialect/Util.java
Index: Util.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/dialect/Util.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Util.java 24 May 2004 16:14:34 -0000 1.3
+++ Util.java 3 Jun 2004 22:48:17 -0000 1.4
@@ -33,7 +33,8 @@
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 HSQL_PART = "hsql";
+
public static int discoverSQLDialect(DatabaseMetaData meta) {
int dialectCode = 0;
@@ -52,6 +53,8 @@
return ConnectionSource.ORACLE_DIALECT;
} else if (dbName.indexOf(MSSQL_PART) != -1) {
return ConnectionSource.MSSQL_DIALECT;
+ } else if (dbName.indexOf(HSQL_PART) != -1) {
+ return ConnectionSource.HSQL_DIALECT;
} else {
return ConnectionSource.UNKNOWN_DIALECT;
}
@@ -82,7 +85,7 @@
sqlDialect = new MsSQLDialect();
break;
- case ConnectionSource.HSQLDB_DIALECT:
+ case ConnectionSource.HSQL_DIALECT:
sqlDialect = new HSQLDBDialect();
break;
1.2 +0 -4 logging-log4j/src/java/org/apache/log4j/db/dialect/hsqldb.sql
Index: hsqldb.sql
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/dialect/hsqldb.sql,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hsqldb.sql 20 May 2004 15:38:00 -0000 1.1
+++ hsqldb.sql 3 Jun 2004 22:48:17 -0000 1.2
@@ -4,10 +4,6 @@
#
# It is intended for HSQLDB.
#
-#
-# ====================================================================
-# WARNING: IT IS ESTABLISHED THAT DBAppender DOES NOT WORK WITH HSQLDB.
-# ====================================================================
DROP TABLE logging_event_exception;
DROP TABLE logging_event_property;
1.8 +5 -1 logging-log4j/src/java/org/apache/log4j/db/ConnectionSource.java
Index: ConnectionSource.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/ConnectionSource.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ConnectionSource.java 26 May 2004 15:36:18 -0000 1.7
+++ ConnectionSource.java 3 Jun 2004 22:48:17 -0000 1.8
@@ -37,7 +37,7 @@
final int MYSQL_DIALECT = 2;
final int ORACLE_DIALECT = 3;
final int MSSQL_DIALECT = 4;
- final int HSQLDB_DIALECT = 5;
+ final 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
@@ -68,4 +68,8 @@
*/
boolean supportsGetGeneratedKeys();
+ /**
+ * If the connection does not support batch updates, we will avoid using them.
+ */
+ public boolean supportsBatchUpdates();
}
1.3 +38 -39 logging-log4j/src/java/org/apache/log4j/db/DBReceiverJob.java
Index: DBReceiverJob.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/DBReceiverJob.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DBReceiverJob.java 24 May 2004 16:14:34 -0000 1.2
+++ DBReceiverJob.java 3 Jun 2004 22:48:17 -0000 1.3
@@ -30,17 +30,20 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-
+import java.util.Vector;
/**
* Actual retrieval of data is made by the instance of DBReceiverJob associated
* with DBReceiver.
- *
+ *
* @author Ceki Gülcü
*/
class DBReceiverJob implements Job {
+
static final Logger logger = Logger.getLogger(DBReceiverJob.class);
+
long lastId = 0;
+
DBReceiver parentDBReceiver;
DBReceiverJob(DBReceiver parent) {
@@ -54,8 +57,8 @@
try {
Logger logger;
- LoggerRepository loggerRepository =
- parentDBReceiver.getLoggerRepository();
+ LoggerRepository loggerRepository = parentDBReceiver
+ .getLoggerRepository();
connection = parentDBReceiver.connectionSource.getConnection();
StringBuffer sql = new StringBuffer();
@@ -81,11 +84,11 @@
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql.toString());
- rs.beforeFirst();
-
+ //rs.beforeFirst();
+
while (rs.next()) {
LoggingEvent event = new LoggingEvent();
-
+
event.setSequenceNumber(rs.getLong(1));
event.setTimeStamp(rs.getLong(2));
event.setRenderedMessage(rs.getString(3));
@@ -98,7 +101,6 @@
event.setNDC(rs.getString(6));
event.setThreadName(rs.getString(7));
-
short mask = rs.getShort(8);
String fileName = rs.getString(9);
@@ -109,18 +111,17 @@
if (fileName.equals(LocationInfo.NA)) {
event.setLocationInformation(LocationInfo.NA_LOCATION_INFO);
} else {
- event.setLocationInformation(
- new LocationInfo(fileName, className, methodName, lineNumber));
+ event.setLocationInformation(new LocationInfo(fileName, className,
+ methodName, lineNumber));
}
long id = rs.getLong(13);
- LogLog.info("Received event with id=" +id);
+ LogLog.info("Received event with id=" + id);
lastId = id;
-
+
// Scott asked for this info to be
event.setProperty(Constants.LOG4J_ID_KEY, Long.toString(id));
-
if ((mask & DBHelper.PROPERTIES_EXIST) != 0) {
getProperties(connection, id, event);
}
@@ -155,17 +156,16 @@
/**
* 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 {
- String sql =
- "SELECT mapped_key, mapped_value FROM logging_event_property WHERE event_id='"
- + id + "'";
+ throws SQLException {
+ String sql = "SELECT mapped_key, mapped_value FROM logging_event_property WHERE event_id='"
+ + id + "'";
Statement statement = null;
@@ -173,7 +173,7 @@
statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
- rs.beforeFirst();
+ //rs.beforeFirst();
while (rs.next()) {
String key = rs.getString(1);
@@ -188,19 +188,18 @@
}
/**
- * Retrieve the exception string representation from the logging_event_exception
- * table.
- *
+ * Retrieve the exception string representation from the
+ * logging_event_exception table.
+ *
* @param connection
* @param id
* @param event
* @throws SQLException
*/
void getException(Connection connection, long id, LoggingEvent event)
- throws SQLException {
- String sql =
- "SELECT i, trace_line FROM logging_event_exception where event_id='"
- + id + "'";
+ throws SQLException {
+ String sql = "SELECT trace_line FROM logging_event_exception where event_id='"
+ + id + "' ORDER by i ASC";
Statement statement = null;
@@ -209,24 +208,24 @@
ResultSet rs = statement.executeQuery(sql);
- // if rs has results, then extract the exception
- if (rs.last()) {
- int len = rs.getRow();
- String[] strRep = new String[len];
- rs.beforeFirst();
-
- while (rs.next()) {
- int i = rs.getShort(1);
- strRep[i] = rs.getString(2);
- }
+ Vector v = new Vector();
+
+ while (rs.next()) {
+ //int i = rs.getShort(1);
+ v.add(rs.getString(1));
+ }
- // we've filled strRep, we now attach it to the event
- event.setThrowableInformation(new ThrowableInformation(strRep));
+ int len = v.size();
+ String[] strRep = new String[len];
+ for (int i = 0; i < len; i++) {
+ strRep[i] = (String) v.get(i);
}
+ // we've filled strRep, we now attach it to the event
+ event.setThrowableInformation(new ThrowableInformation(strRep));
} finally {
if (statement != null) {
statement.close();
}
}
}
-}
+}
\ No newline at end of file
1.7 +2 -12 logging-log4j/src/java/org/apache/log4j/db/DataSourceConnectionSource.java
Index: DataSourceConnectionSource.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/DataSourceConnectionSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DataSourceConnectionSource.java 24 May 2004 16:14:34 -0000 1.6
+++ DataSourceConnectionSource.java 3 Jun 2004 22:48:17 -0000 1.7
@@ -16,11 +16,10 @@
package org.apache.log4j.db;
-import org.apache.log4j.db.dialect.Util;
+
import org.apache.log4j.helpers.LogLog;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import javax.sql.DataSource;
@@ -56,20 +55,11 @@
LogLog.warn("Could not get a connection to discover the dialect to use.", se);
}
if(connection != null) {
- try {
- DatabaseMetaData meta = connection.getMetaData();
- supportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
- if(!supportsGetGeneratedKeys) {
- dialectCode = Util.discoverSQLDialect(meta);
- }
- } catch(SQLException sqle) {
- LogLog.warn("Could not get a discover connection properties.");
- }
+ discoverConnnectionProperties();
}
if(!supportsGetGeneratedKeys && dialectCode == ConnectionSource.UNKNOWN_DIALECT) {
LogLog.warn("Connection does not support GetGeneratedKey method and could not discover the dialect.");
}
-
}
}
1.14 +123 -97 logging-log4j/src/java/org/apache/log4j/db/DBAppender.java
Index: DBAppender.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/DBAppender.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DBAppender.java 26 May 2004 15:36:18 -0000 1.13
+++ DBAppender.java 3 Jun 2004 22:48:17 -0000 1.14
@@ -32,88 +32,102 @@
import java.util.Iterator;
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.
+ * 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>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>
+ * 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>
*
* <table border="1" cellpadding="4">
- * <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>
+ * <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>
+ *
* </table>
- * <p><b>Performance:</b> Experiments show that writing a single event into the
+ * <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.
+ * most JDBC drivers already ship with connection pooling support.
* </p>
- *
*
*
- * <p><b>Configuration</b> DBAppender can be configured programmatically, or
- * using {@link org.apache.log4j.joran.JoranConfigurator JoranConfigurator}.
- * Example scripts can be found in the <em>tests/input/db</em> directory.
+ *
+ * <p>
+ * <b>Configuration </b> DBAppender can be configured programmatically, or using
+ * {@link org.apache.log4j.joran.JoranConfigurator JoranConfigurator}. Example
+ * scripts can be found in the <em>tests/input/db</em> directory.
*
* @author Ceki Gülcü
* @author Ray DeCampo
* @since 1.3
*/
public class DBAppender extends AppenderSkeleton {
+
ConnectionSource connectionSource;
+
boolean cnxSupportsGetGeneratedKeys = false;
+ boolean cnxSupportsBatchUpdates = false;
SQLDialect sqlDialect;
+
boolean locationInfo = false;
-
- 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 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 {StringBuffer sql = new StringBuffer();
+ static {
+ StringBuffer sql = new StringBuffer();
sql.append("INSERT INTO logging_event (");
sql.append("sequence_number, ");
sql.append("timestamp, ");
@@ -130,24 +144,21 @@
sql.append(" VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?)");
insertSQL = sql.toString();
}
-
+
public DBAppender() {
- }
+ }
+
public void activateOptions() {
LogLog.debug("DBAppender.activateOptions called");
- if (connectionSource == null) {
- throw new IllegalStateException(
- "DBAppender cannot function without a connection source");
- }
+ if (connectionSource == null) { throw new IllegalStateException(
+ "DBAppender cannot function without a connection source"); }
sqlDialect = Util.getDialectFromCode(connectionSource.getSQLDialectCode());
cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys();
-
- 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");
- }
+ 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"); }
}
/**
@@ -158,7 +169,8 @@
}
/**
- * @param connectionSource The connectionSource to set.
+ * @param connectionSource
+ * The connectionSource to set.
*/
public void setConnectionSource(ConnectionSource connectionSource) {
LogLog.debug("setConnectionSource called for DBAppender");
@@ -171,7 +183,8 @@
connection = connectionSource.getConnection();
connection.setAutoCommit(false);
- PreparedStatement insertStatement = connection.prepareStatement(insertSQL);
+ PreparedStatement insertStatement = connection
+ .prepareStatement(insertSQL);
insertStatement.setLong(1, event.getSequenceNumber());
insertStatement.setLong(2, event.getTimeStamp());
insertStatement.setString(3, event.getRenderedMessage());
@@ -202,26 +215,27 @@
Statement idStatement = connection.createStatement();
idStatement.setMaxRows(1);
-
ResultSet rs = null;
- if(cnxSupportsGetGeneratedKeys) {
- rs = insertStatement.getGeneratedKeys();
- } else {
- rs = idStatement.executeQuery(sqlDialect.getSelectInsertId());
- }
- rs.first();
+ if (cnxSupportsGetGeneratedKeys) {
+ rs = insertStatement.getGeneratedKeys();
+ } else {
+ 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);
// we no longer need the insertStatement
insertStatement.close();
insertStatement = null;
-
+
Set propertiesKeys = event.getPropertyKeySet();
if (propertiesKeys.size() > 0) {
- PreparedStatement insertPropertiesStatement =
- connection.prepareStatement(insertPropertiesSQL);
+ PreparedStatement insertPropertiesStatement = connection
+ .prepareStatement(insertPropertiesSQL);
for (Iterator i = propertiesKeys.iterator(); i.hasNext();) {
String key = (String) i.next();
@@ -230,10 +244,18 @@
insertPropertiesStatement.setInt(1, eventId);
insertPropertiesStatement.setString(2, key);
insertPropertiesStatement.setString(3, value);
- insertPropertiesStatement.addBatch();
+
+ if(cnxSupportsBatchUpdates) {
+ insertPropertiesStatement.addBatch();
+ } else {
+ insertPropertiesStatement.execute();
+ }
}
- insertPropertiesStatement.executeBatch();
+ if(cnxSupportsBatchUpdates) {
+ insertPropertiesStatement.executeBatch();
+ }
+
insertPropertiesStatement.close();
insertPropertiesStatement = null;
}
@@ -243,17 +265,22 @@
if (strRep != null) {
LogLog.info("Logging an exception");
- PreparedStatement insertExceptionStatement =
- connection.prepareStatement(insertExceptionSQL);
+ 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]);
- insertExceptionStatement.addBatch();
+ if(cnxSupportsBatchUpdates) {
+ insertExceptionStatement.addBatch();
+ } else {
+ insertExceptionStatement.execute();
+ }
+ }
+ if(cnxSupportsBatchUpdates) {
+ insertExceptionStatement.executeBatch();
}
-
- insertExceptionStatement.executeBatch();
insertExceptionStatement.close();
insertExceptionStatement = null;
}
@@ -266,7 +293,6 @@
}
}
-
public void close() {
closed = true;
}
@@ -279,19 +305,19 @@
}
/**
- * Returns value of the <b>LocationInfo</b> property which determines whether
+ * 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.
- * */
+ * 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;
}
-}
+}
\ No newline at end of file
1.6 +12 -1 logging-log4j/src/java/org/apache/log4j/db/ConnectionSourceSkeleton.java
Index: ConnectionSourceSkeleton.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/ConnectionSourceSkeleton.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConnectionSourceSkeleton.java 2 Jun 2004 20:57:27 -0000 1.5
+++ ConnectionSourceSkeleton.java 3 Jun 2004 22:48:17 -0000 1.6
@@ -36,6 +36,8 @@
// initially we have an unkonw dialect
protected int dialectCode = UNKNOWN_DIALECT;
protected boolean supportsGetGeneratedKeys = false;
+ protected boolean supportsBatchUpdates = false;
+
/**
* Learn relevant information about this connection source.
@@ -50,6 +52,7 @@
}
DatabaseMetaData meta = connection.getMetaData();
supportsGetGeneratedKeys = supportsGetGeneratedKeys(meta);
+ supportsBatchUpdates = meta.supportsBatchUpdates();
dialectCode = Util.discoverSQLDialect(meta);
} catch (SQLException se) {
LogLog.warn("Could not discover the dialect to use.", se);
@@ -61,7 +64,7 @@
return meta.supportsGetGeneratedKeys();
} catch(Throwable e) {
LogLog.warn("The following warning is only informative.");
- LogLog.warn("Could not call supportsGetGeneratedKeys method. This may be recoverable", e);
+ LogLog.warn("Could not call supportsGetGeneratedKeys method. This may be recoverable");
return false;
}
}
@@ -122,4 +125,12 @@
public void setUser(String username) {
this.user = username;
}
+
+ /**
+ * Does this connection support batch updates?
+ */
+ public boolean supportsBatchUpdates() {
+ return supportsBatchUpdates;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org