• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

authentication org.postgresql.util.PSQLException

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Experimented successfully with the UserDatabaseRealm - and I'm now attempting to implement a JDBCRealm with PostgreSQL 9.05

Receiving the following Tomcat error when trying to open the admin/manager GUIs:



Tried JDBC drivers postgresql-8.4-702.jdbc3.jar & postgresql-8.4-702.jdbc4.jar - both produce the same error.

Tomcat Console output:











Ruled out a problem with the connectionURL, connectionName, connectionPassword and userTable by systematically snarking these up to see how/if Tomcat would fail. All presently have reasonable values that seem to be acceptable to Tomcat.

I have tried renaming the userName and userCredCol database columns/realm attributes - the same problem persists - the only difference being that the cred column it complains about has the new name.

What have I got wrong? I'm at a loss with regard to what else to try...
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are quoting your column names in the DDL. That usually changes how upper/lower case column names are defined and referenced, although it depends on the database.

What that probably means is that the SQL query is being treated like you coded "SELECT NAME, CREDENTIAL ...", but the actual column name was "credential" and didn't match because it was lower-case.

You can check the PostgreSQL docs to verify, but if that is, in fact what is wrong, then you should either remove the double-quotes from the DDL definitions OR make the quoted names be in uppercase.
 
John Neoheurist
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As it turned out the userCredCol="credential" attribute was not the problem - it was an indirect victim of the userTable="user" attribute. Because user is a keyword in Postgres when Tomcat uses the value of the userTable attribute it doesn't bother to quote its value and thereby produces an SQL syntax error when it attempts to reference the user table. The reason I needed the quotes in the DDL was to get around the fact that user is a keyword thus making the SQL generated by Tomcat inconsistent with the DDL (@Tim, your hint regarding the quotes put me on the right track - THANKS!).

Tangentially thought: While the following make complete sense in retrospect - I find it odd that the Tomcat documentation doesn't emphasize the fact that the userNameCol attribute actually qualifies both the userTable and the userRoleTable (e.g. both tables must have a column of the same name that can be joined upon to extract roles for a user).
 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Neoheurist wrote:
Tangentially thought: While the following make complete sense in retrospect - I find it odd that the Tomcat documentation doesn't emphasize the fact that the userNameCol attribute actually qualifies both the userTable and the userRoleTable (e.g. both tables must have a column of the same name that can be joined upon to extract roles for a user).



Well, if one is expecting a "role" to be an essential user attribute, it might not make sense. A lot of people don't realize that a user can possess more than one role, but that ability is, in fact a very powerful attribute of the J2EE security architecture. If a user could never be in more than one role, there really wouldn't even be a need for a separate role table, but since it's a one-to-many relationship, you need a link between the table that defines users and the table that defines roles for that user, and the userId is a natural candidate for that linkage.
 
reply
    Bookmark Topic Watch Topic
  • New Topic