At 20:00 12.02.2003 -0500, Raymond DeCampo wrote:
When I looked over the code, my first thought is that it should use a PreparedStatement instead of a Statement. In this way you will solve a great number of issues (e.g. escaping ' in string literals would not be necessary). The configuration can match the order of the ?s to the properties of the logging event. The code can use PreparedStatement.setObject() to set the parameters and let the JDBC driver worry about mapping types. This would improve performance as well (at least in theory).
I share the same assessment.
Another improvement that immediately comes to mind is an option to use JNDI to get a DataSource instead of specifying the Connection. This would improve performance greatly on application servers where you would get connection pooling. Unfortunately I don't think that really makes the class easier to implement/maintain. (Probably the way to go here would be an abstract base class with an abstract getConnection() method with two concrete classes which get the connection in the two different manners.)
Ditto.
As far as CLOBs go, they can be problematic. For whatever reason, there is no standard way in the JDBC specification to create a java.sql.Clob object for use in the PreparedStatement.setClob() method. The alternative is to use the setXXXStream() methods which are not always implemented in JDBC drivers (at least in one I am familiar with).
This one is tougher. One possibility is to cater for the most popular databases (Postgres, MySQL, DB2, Oracle) and allow adaptable hooks for the others. At closer analysis, most the data that log4j serializes (or needs to store) is either a java primitive or a String with the exception of ThrowableInformation, which is essentially an array of strings, and the MDC (a hashmap of strings). These two structures could be placed in two separate tables. Thus, there would be no need for clobs or anything that varies from db to db.
--Ray
Ceki
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]