You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/02/27 16:12:32 UTC

DO NOT REPLY [Bug 6721] New: - JDBCRealm with certain JDBC drivers does not work

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6721>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6721

JDBCRealm with certain JDBC drivers does not work

           Summary: JDBCRealm with certain JDBC drivers does not work
           Product: Tomcat 4
           Version: 4.0.2 Final
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: dfreund@beam.ag


I tried to create a JDBCRealm connecting to Firebird 1.0 using Interclient-JDBC
drivers. My configuration of server.xml/web.xml is nearly the same as described
in the Tomcat examples. The configuration worked fine with mySQL. When using
Firebird, I got the following exception, when I entered the JDBCRealm:

java.lang.NullPointerException
	at interbase.interclient.PreparedStatement.setString(PreparedStatement.java:979)
	at org.apache.catalina.realm.JDBCRealm.credentials(JDBCRealm.java:484)
	at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:376)
	at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:326)

I found out that on the first time you enter a ressource in the JDBCRealm, the
method credential sets the username to null:
  preparedCredentials.setString(1, username);
Some JDBC drivers want to have a correct set String. The following patch of the
method authenticate(Connection dbConnection, String username, String
credentials) did the job:

 [snip]
        // Look up the user's credentials
        String dbCredentials = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        
        try {
            stmt = credentials(dbConnection, username);
            rs = stmt.executeQuery();
            while (rs.next()) {
                dbCredentials = rs.getString(1).trim();
            }
            rs.close();
        }
        catch (Exception ex) {
            // some JDBC drivers are throwing a null pointer exception
            // if the prepared statement parameter is set to null
        }

        if (dbCredentials == null) {
            return (null);
        }
   [snip]

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>