You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bip Thelin <bi...@sf.razorfish.com> on 2000/06/19 04:24:48 UTC

[PATCH] JDBCRealm problem with Oracle

Resolvs a problem i had when connecting with Oracledriver.

	..bip

Index: JDBCRealm.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/request/JDBCRealm.java,v
retrieving revision 1.4
diff -r1.4 JDBCRealm.java
121a122,131
>      * The connection URL to use when trying to connect to the databse
>      */
>     private String connectionName = null;
> 
>     /**
>      * The connection URL to use when trying to connect to the databse
>      */
>     private String connectionPassword = null;
> 
>     /**
207a218,235
>      * Set the name to use to connect to the database.
>      *
>      * @param connectionName User name
>      */
>     public void setConnectionName(String connectionName) {
>         this.connectionName = connectionName;
>     }
> 
>     /**
>      * Set the password to use to connect to the database.
>      *
>      * @param connectionPassword User password
>      */
>     public void setConnectionPassword(String connectionPassword) {
>         this.connectionPassword = connectionPassword;
>     }
> 
>     /**
364c392,399
<             dbConnection = DriverManager.getConnection(connectionURL);
---
>             if ((connectionName.equals("") || connectionName == null) &&
>                 (connectionPassword.equals("") || connectionPassword == null)) {
>                 dbConnection = DriverManager.getConnection(connectionURL);
>             } else {
>                 dbConnection = DriverManager.getConnection(connectionURL,
>                                                            connectionName,
>                                                            connectionPassword);
>             }
Index: JDBCRealm.howto
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/doc/JDBCRealm.howto,v
retrieving revision 1.2
diff -r1.2 JDBCRealm.howto
103a104,106
>    Optional:
>      connectionName -> The name to use when connecting to the database.
>      connectionPassword -> The password to use when connecting to the database.
113a117,126
>    - If you have problem connecting you can specify connectionName and connectionPassword:
> 
>     <RequestInterceptor className="org.apache.tomcat.realm.JDBCRealm"
>      debug="99"
>      driverName="oracle.jdbc.driver.OracleDriver"
>      connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
>      connectionName="scott"
>      connectionPassword="tiger"
>      userTable="users" userNameCol="user_name" userCredCol="user_pass"
>      userRoleTable="user_roles" roleNameCol="role_name" />
Index: server.xml
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat/src/etc/server.xml,v
retrieving revision 1.24
diff -r1.24 server.xml
103c103,104
<                               "?user=scott;password=tiger"  
---
>               connectionName="scott"
>               connectionPassword="tiger"
107c108,109
<                             "?user=test;password=test"
---
>               connectionName="test"
>               connectionPassword="test"
108a111
>             "connectionName" and "connectionPassword" are optional.

Re: [PATCH] JDBCRealm problem with Oracle

Posted by Marius Sorin Barduta <ma...@necomm.ro>.
The test for null must precede the method call on an object so the code for
the following snippet should be:

<snip>

            if   (    (  connectionName == null ||
ectionName.equals("")     ) &&
                      (  connectionPassword == null ||
connectionPassword.equals("") )  ) {
                 dbConnection = DriverManager.getConnection(connectionURL);
             } else {
                 dbConnection = DriverManager.getConnection(connectionURL,
                                                            connectionName,

connectionPassword);
          }

</snip>

regards,
Marius


> 364c392,399
> > ---
> >             if ((connectionName.equals("") || connectionName == null) &&
> >                 (connectionPassword.equals("") || connectionPassword ==
null)) {
> >                 dbConnection =
DriverManager.getConnection(connectionURL);
> >             } else {
> >                 dbConnection =
DriverManager.getConnection(connectionURL,
> >
connectionName,
> >
connectionPassword);
> >             }