Bug 38052 - JDBCAccessLogValve uses reserved word "user" as column name
JDBCAccessLogValve uses reserved word "user" as column name
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.14
All All
: P5 trivial (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-12-27 14:28 UTC by rik
Modified: 2012-02-17 18:13 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rik 2005-12-27 14:28:45 UTC
org.apache.catalina.valves.JDBCAccessLogValve  

It is more a documentation problem than a bug

For the table access the column name "user" is used. This is a reserved word in
SQL92, and causes problems with Postgres 8.0.3
Comment 1 Yoav Shapira 2006-04-13 21:40:17 UTC
Suggested fix?
Comment 2 rik 2006-04-14 06:49:47 UTC
(In reply to comment #1)
> Suggested fix?

Change to "username" or \"user\" (with quotes) in line 79 and 146 
Comment 3 Peter Rossbach 2006-04-14 07:29:08 UTC
You can change it at your JDBCValve

 <Valve className="JDBCAccessLogValve"
        	        driverName="your_jdbc_driver"
         	connectionURL="your_jdbc_url"
         	pattern="combined" resolveHosts="false"
                userField="userName"
 />

But I also think user is not a nice default, and we better change it.
Thanks reporting it.

Comment 4 Trooprex 2012-02-16 09:56:28 UTC
How do we get this Valve working for Oracle.

1. Oracle doesn't have Auto_Increment, instead they have sequences.
2. Oracle cannot directly create a table as access. It had to be "access".
   (Anyways I worked it around with tableName = "accesslogs" in the server.xml)

I had to strip down the table struct to this 

CREATE TABLE accesslogs (
 id VARCHAR(255),
 remoteHost CHAR(15),
 userName CHAR(15),
 timestamp TIMESTAMP,
 virtualHost VARCHAR(64),
 method VARCHAR(8),
 query VARCHAR(255),
 status SMALLINT,
 bytes INT,
 referer VARCHAR(128),
 userAgent VARCHAR(128)
  );

Can this valve provide fix for the default table struct?

Also, the valve fails to log in the Oracle DB if I use the following pattern 

pattern="Combined Log Format: %{X-Forwarded-For}i %a %h %q %v %D %T %l %u %t %r %s %b %{User-Agent}i %{Referer}i"

It works well for pattern="combined"
Comment 5 Mark Thomas 2012-02-17 18:13:56 UTC
Bugzilla is not a support forum. Please direct your questions to the Tomcat users mailing list rather than re-opening a five year old resolved bug.