You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Amitava Chakraborty <am...@in.ibm.com> on 2008/01/28 07:23:00 UTC

db.getConnection() working but db.getConnection("username","password") not working for JNDI Connection

Hi ALL,

I am using

 java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511
(SR2))

IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32
j9vmwi3223-2006050
4 (JIT enabled)
J9VM - 20060501_06428_lHdSMR
JIT  - 20060428_1800_r8
GC   - 20060501_AA)
JCL  - 20060511a

Tomcat 5.5.21

DataBase : Informix V 11.10   Informix JDBC Driver 3.10 JC1

During connecting through JNDI datasource , db.getConnection() is working
perfectly. But db.getConnection("myusername", "myPassword") is not working.
It is saying

java.lang.UnsupportedOperationException: Not supported by BasicDataSource

org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:899)

But I checked the
 http://java.sun.com/j2se/1.5.0
/docs/api/javax/sql/DataSource.html#getConnection(java.lang.String,%20java.lang.String)

where it is saying getconnection method with username and password is
supported. I am using javax.sql.DataSource. I donot want to use my username
and password in the context.xml or server.xml for security issue. Please
help me how can I do it.

Thanks
Amitava


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: db.getConnection() working but db.getConnection("username","password") not working for JNDI Connection

Posted by David Smith <dn...@cornell.edu>.
But if you take a look at the javadocs for BasicDataSource in 
Commons-DBCP, you'll find the DBCP implementation of the DataSource 
interface does not support the getConnection( user, password ) method.

http://commons.apache.org/dbcp/apidocs/index.html

--David

Amitava Chakraborty wrote:
> Hi ALL,
>
> I am using
>
>  java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511
> (SR2))
>
> IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32
> j9vmwi3223-2006050
> 4 (JIT enabled)
> J9VM - 20060501_06428_lHdSMR
> JIT  - 20060428_1800_r8
> GC   - 20060501_AA)
> JCL  - 20060511a
>
> Tomcat 5.5.21
>
> DataBase : Informix V 11.10   Informix JDBC Driver 3.10 JC1
>
> During connecting through JNDI datasource , db.getConnection() is working
> perfectly. But db.getConnection("myusername", "myPassword") is not working.
> It is saying
>
> java.lang.UnsupportedOperationException: Not supported by BasicDataSource
>
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:899)
>
> But I checked the
>  http://java.sun.com/j2se/1.5.0
> /docs/api/javax/sql/DataSource.html#getConnection(java.lang.String,%20java.lang.String)
>
> where it is saying getconnection method with username and password is
> supported. I am using javax.sql.DataSource. I donot want to use my username
> and password in the context.xml or server.xml for security issue. Please
> help me how can I do it.
>
> Thanks
> Amitava
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: db.getConnection() working but db.getConnection("username","password") notworking for JNDI Connection

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Amitava Chakraborty [mailto:amitacha@in.ibm.com] 
> Subject: db.getConnection() working but 
> db.getConnection("username","password") notworking for JNDI Connection
> 
> I am using javax.sql.DataSource.

No, you're using the connections pooling logic, which wrappers
javax.sql.DataSource.  If you're going to use container-managed
connection pooling, the container must be aware of the database
credentials, not the webapp.

> I donot want to use my username and password in the context.xml
> or server.xml for security issue.

A misplaced concern.  If your Tomcat and webapp configuration files
aren't secure, then you have many other problems to worry about than
just database access.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org