[DBCP] mysql authentication

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[DBCP] mysql authentication

Tom Mathews
I'm trying to set up a connection pool to a mysql 5 db using JSP on
Tomcat 5, versions as follows:

mysql-connector-java-3.1.8
jakarta-tomcat-5.0.28
Mysql-devel-5.0.3
Mandrake 10.1 on AMD64



I've a resource set up which includes username and password elements#
...
   <!-- MySQL dB username and password for dB connections  -->
    <parameter>
     <name>username</name>
     <value>myUser</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>myPassword</value>
    </parameter>
...
but whenever I try and run the pages that use this, I get an error back  
saying
'Cannot create PoolableConnectionFactory (Access denied for user
'myUser'@'me.mydomain.com' (using password: NO) '

If I create a new database user with no password, then I can connect
fine, but this is obviously not something that I want to do!

Does anyone know how to make tomcat / mysql/J use a password (JSP rather
than a stand alone java class, which is working absolutely fine).

Thanks
Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [DBCP] mysql authentication

Larner, Ross S
Tom,
If I remember correctly, the -p switch is used to supply the password.

Ross

-----Original Message-----
From: Tom Mathews [mailto:[hidden email]]
Sent: Monday, June 13, 2005 4:05 AM
To: jakarta commons
Subject: [DBCP] mysql authentication

I'm trying to set up a connection pool to a mysql 5 db using JSP on
Tomcat 5, versions as follows:

mysql-connector-java-3.1.8
jakarta-tomcat-5.0.28
Mysql-devel-5.0.3
Mandrake 10.1 on AMD64



I've a resource set up which includes username and password elements#
...
   <!-- MySQL dB username and password for dB connections  -->
    <parameter>
     <name>username</name>
     <value>myUser</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>myPassword</value>
    </parameter>
...
but whenever I try and run the pages that use this, I get an error back
saying 'Cannot create PoolableConnectionFactory (Access denied for user
'myUser'@'me.mydomain.com' (using password: NO) '

If I create a new database user with no password, then I can connect
fine, but this is obviously not something that I want to do!

Does anyone know how to make tomcat / mysql/J use a password (JSP rather
than a stand alone java class, which is working absolutely fine).

Thanks
Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [DBCP] mysql authentication

Tom Mathews
-p certainly works on the command line, but do you have any hints as to
how to insert this programatically in a connection pool?
My code looks (alot!) like this (please note there may be typo's - the
machine I'm typing this from is isolated from my dev environment so I
can't just copy paste!)
...
try
{
String jdbcname = "jdbc/myApp";
String cmd = "SELECT * FROM client WHERE clientRef > 0";
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup(jdbcname);
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement;
ResultSet rs = stmt.executeQuery(cmd);
ResultSetMetaData rsmd = rs.getMetaData();
....
Thanks
Tom

Larner, Ross S wrote:

>Tom,
>If I remember correctly, the -p switch is used to supply the password.
>
>Ross
>
>-----Original Message-----
>From: Tom Mathews [mailto:[hidden email]]
>Sent: Monday, June 13, 2005 4:05 AM
>To: jakarta commons
>Subject: [DBCP] mysql authentication
>
>I'm trying to set up a connection pool to a mysql 5 db using JSP on
>Tomcat 5, versions as follows:
>
>mysql-connector-java-3.1.8
>jakarta-tomcat-5.0.28
>Mysql-devel-5.0.3
>Mandrake 10.1 on AMD64
>
>
>
>I've a resource set up which includes username and password elements#
>...
>   <!-- MySQL dB username and password for dB connections  -->
>    <parameter>
>     <name>username</name>
>     <value>myUser</value>
>    </parameter>
>    <parameter>
>     <name>password</name>
>     <value>myPassword</value>
>    </parameter>
>...
>but whenever I try and run the pages that use this, I get an error back
>saying 'Cannot create PoolableConnectionFactory (Access denied for user
>'myUser'@'me.mydomain.com' (using password: NO) '
>
>If I create a new database user with no password, then I can connect
>fine, but this is obviously not something that I want to do!
>
>Does anyone know how to make tomcat / mysql/J use a password (JSP rather
>than a stand alone java class, which is working absolutely fine).
>
>Thanks
>Tom
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [DBCP] mysql authentication

Larner, Ross S
In reply to this post by Tom Mathews
Hey Tom,
Forewarning - I have little knowledge of DBCP, so this may be breaking
the paradigm.

I don't know if you have access to the jdbc drivers for mysql, but if
so, you should be able to pass the password into the call to retrieve
the connection:

      Connection con =
                     DriverManager.getConnection(
                                 url,"root", "password");

Take a look at this article:
http://www.developer.com/java/data/article.php/3417381

Ross

-----Original Message-----
From: Tom Mathews [mailto:[hidden email]]
Sent: Monday, June 13, 2005 10:42 AM
To: Jakarta Commons Users List
Subject: Re: [DBCP] mysql authentication

-p certainly works on the command line, but do you have any hints as to
how to insert this programatically in a connection pool?
My code looks (alot!) like this (please note there may be typo's - the
machine I'm typing this from is isolated from my dev environment so I
can't just copy paste!) ...
try
{
String jdbcname = "jdbc/myApp";
String cmd = "SELECT * FROM client WHERE clientRef > 0"; Context ctx =
new InitialContext(); Context envCtx =
(Context)ctx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup(jdbcname);
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement;
ResultSet rs = stmt.executeQuery(cmd);
ResultSetMetaData rsmd = rs.getMetaData(); ....
Thanks
Tom

Larner, Ross S wrote:

>Tom,
>If I remember correctly, the -p switch is used to supply the password.
>
>Ross
>
>-----Original Message-----
>From: Tom Mathews [mailto:[hidden email]]
>Sent: Monday, June 13, 2005 4:05 AM
>To: jakarta commons
>Subject: [DBCP] mysql authentication
>
>I'm trying to set up a connection pool to a mysql 5 db using JSP on
>Tomcat 5, versions as follows:
>
>mysql-connector-java-3.1.8
>jakarta-tomcat-5.0.28
>Mysql-devel-5.0.3
>Mandrake 10.1 on AMD64
>
>
>
>I've a resource set up which includes username and password elements#
>...
>   <!-- MySQL dB username and password for dB connections  -->
>    <parameter>
>     <name>username</name>
>     <value>myUser</value>
>    </parameter>
>    <parameter>
>     <name>password</name>
>     <value>myPassword</value>
>    </parameter>
>...
>but whenever I try and run the pages that use this, I get an error back

>saying 'Cannot create PoolableConnectionFactory (Access denied for user

>'myUser'@'me.mydomain.com' (using password: NO) '
>
>If I create a new database user with no password, then I can connect
>fine, but this is obviously not something that I want to do!
>
>Does anyone know how to make tomcat / mysql/J use a password (JSP
>rather than a stand alone java class, which is working absolutely
fine).

>
>Thanks
>Tom
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [DBCP] mysql authentication

Pramodh Peddi
In reply to this post by Tom Mathews
Tom,

I am sorry I am not yet good enough to help you, but I have a question
for you. I will appreciate if you can answer.

 

Can you present your whole xml related to DBCP from server.xml? I am
using the exact format given in
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
-howto.html, but not sure what is happening, it says " Could not connect
to the DB: org.apache.commons.dbcp.SQLNestedException: Cannot create
JDBC driver of class '' for connect URL 'null', cause: No suitable
driver".

 

Should these parameters be in Resource element or ResourceParams
element? I am sure getting the DataSource object is working fine as the
Exception is being thrown at ds.getConnection().

 

Thanks in advance.

 

Pramodh.

 

-----Original Message-----
From: Tom Mathews [mailto:[hidden email]]
Sent: Monday, June 13, 2005 1:42 PM
To: Jakarta Commons Users List
Subject: Re: [DBCP] mysql authentication

 

-p certainly works on the command line, but do you have any hints as to

how to insert this programatically in a connection pool?

My code looks (alot!) like this (please note there may be typo's - the

machine I'm typing this from is isolated from my dev environment so I

can't just copy paste!)

...

try

{

String jdbcname = "jdbc/myApp";

String cmd = "SELECT * FROM client WHERE clientRef > 0";

Context ctx = new InitialContext();

Context envCtx = (Context)ctx.lookup("java:comp/env");

DataSource ds = (DataSource)envCtx.lookup(jdbcname);

Connection conn = ds.getConnection();

Statement stmt = conn.createStatement;

ResultSet rs = stmt.executeQuery(cmd);

ResultSetMetaData rsmd = rs.getMetaData();

....

Thanks

Tom

 

Larner, Ross S wrote:

 

>Tom,

>If I remember correctly, the -p switch is used to supply the password.

>

>Ross

>

>-----Original Message-----

>From: Tom Mathews [mailto:[hidden email]]

>Sent: Monday, June 13, 2005 4:05 AM

>To: jakarta commons

>Subject: [DBCP] mysql authentication

>

>I'm trying to set up a connection pool to a mysql 5 db using JSP on

>Tomcat 5, versions as follows:

>

>mysql-connector-java-3.1.8

>jakarta-tomcat-5.0.28

>Mysql-devel-5.0.3

>Mandrake 10.1 on AMD64

>

>

>

>I've a resource set up which includes username and password elements#

>...

>   <!-- MySQL dB username and password for dB connections  -->

>    <parameter>

>     <name>username</name>

>     <value>myUser</value>

>    </parameter>

>    <parameter>

>     <name>password</name>

>     <value>myPassword</value>

>    </parameter>

>...

>but whenever I try and run the pages that use this, I get an error back

>saying 'Cannot create PoolableConnectionFactory (Access denied for user

>'myUser'@'me.mydomain.com' (using password: NO) '

>

>If I create a new database user with no password, then I can connect

>fine, but this is obviously not something that I want to do!

>

>Does anyone know how to make tomcat / mysql/J use a password (JSP
rather

>than a stand alone java class, which is working absolutely fine).

>

>Thanks

>Tom

>

>

>

>---------------------------------------------------------------------

>To unsubscribe, e-mail: [hidden email]

>For additional commands, e-mail: [hidden email]

>

>

>

>

>---------------------------------------------------------------------

>To unsubscribe, e-mail: [hidden email]

>For additional commands, e-mail: [hidden email]

>

>

>

>  

>

 

 

 

---------------------------------------------------------------------

To unsubscribe, e-mail: [hidden email]

For additional commands, e-mail: [hidden email]

 

Reply | Threaded
Open this post in threaded view
|

Re: [DBCP] mysql authentication

Tom Mathews
Pramodh
I could send you it, but the relevent section is all listed below. I use Tomcat 5, so the format is different from the tomcat 4 that you are using. I just took the xml pretty well directly from the mysql help files (http://dev.mysql.com/doc/connector/j/en/)
Tom


Pramodh Peddi wrote:

>Tom,
>
>I am sorry I am not yet good enough to help you, but I have a question
>for you. I will appreciate if you can answer.
>
>
>
>Can you present your whole xml related to DBCP from server.xml? I am
>using the exact format given in
>http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
>-howto.html, but not sure what is happening, it says " Could not connect
>to the DB: org.apache.commons.dbcp.SQLNestedException: Cannot create
>JDBC driver of class '' for connect URL 'null', cause: No suitable
>driver".
>
>
>
>Should these parameters be in Resource element or ResourceParams
>element? I am sure getting the DataSource object is working fine as the
>Exception is being thrown at ds.getConnection().
>
>
>
>Thanks in advance.
>
>
>
>Pramodh.
>
>
>
>-----Original Message-----
>From: Tom Mathews [mailto:[hidden email]]
>Sent: Monday, June 13, 2005 1:42 PM
>To: Jakarta Commons Users List
>Subject: Re: [DBCP] mysql authentication
>
>
>
>-p certainly works on the command line, but do you have any hints as to
>
>how to insert this programatically in a connection pool?
>
>My code looks (alot!) like this (please note there may be typo's - the
>
>machine I'm typing this from is isolated from my dev environment so I
>
>can't just copy paste!)
>
>...
>
>try
>
>{
>
>String jdbcname = "jdbc/myApp";
>
>String cmd = "SELECT * FROM client WHERE clientRef > 0";
>
>Context ctx = new InitialContext();
>
>Context envCtx = (Context)ctx.lookup("java:comp/env");
>
>DataSource ds = (DataSource)envCtx.lookup(jdbcname);
>
>Connection conn = ds.getConnection();
>
>Statement stmt = conn.createStatement;
>
>ResultSet rs = stmt.executeQuery(cmd);
>
>ResultSetMetaData rsmd = rs.getMetaData();
>
>....
>
>Thanks
>
>Tom
>
>
>
>Larner, Ross S wrote:
>
>
>
>  
>
>>Tom,
>>    
>>
>
>  
>
>>If I remember correctly, the -p switch is used to supply the password.
>>    
>>
>
>  
>
>
>  
>
>>Ross
>>    
>>
>
>  
>
>
>  
>
>>-----Original Message-----
>>    
>>
>
>  
>
>>From: Tom Mathews [mailto:[hidden email]]
>>    
>>
>
>  
>
>>Sent: Monday, June 13, 2005 4:05 AM
>>    
>>
>
>  
>
>>To: jakarta commons
>>    
>>
>
>  
>
>>Subject: [DBCP] mysql authentication
>>    
>>
>
>  
>
>
>  
>
>>I'm trying to set up a connection pool to a mysql 5 db using JSP on
>>    
>>
>
>  
>
>>Tomcat 5, versions as follows:
>>    
>>
>
>  
>
>
>  
>
>>mysql-connector-java-3.1.8
>>    
>>
>
>  
>
>>jakarta-tomcat-5.0.28
>>    
>>
>
>  
>
>>Mysql-devel-5.0.3
>>    
>>
>
>  
>
>>Mandrake 10.1 on AMD64
>>    
>>
>
>  
>
>
>  
>
>
>  
>
>
>  
>
>>I've a resource set up which includes username and password elements#
>>    
>>
>
>  
>
>>...
>>    
>>
>
>  
>
>>  <!-- MySQL dB username and password for dB connections  -->
>>    
>>
>
>  
>
>>   <parameter>
>>    
>>
>
>  
>
>>    <name>username</name>
>>    
>>
>
>  
>
>>    <value>myUser</value>
>>    
>>
>
>  
>
>>   </parameter>
>>    
>>
>
>  
>
>>   <parameter>
>>    
>>
>
>  
>
>>    <name>password</name>
>>    
>>
>
>  
>
>>    <value>myPassword</value>
>>    
>>
>
>  
>
>>   </parameter>
>>    
>>
>
>  
>
>>...
>>    
>>
>
>  
>
>>but whenever I try and run the pages that use this, I get an error back
>>    
>>
>
>  
>
>>saying 'Cannot create PoolableConnectionFactory (Access denied for user
>>    
>>
>
>  
>
>>'myUser'@'me.mydomain.com' (using password: NO) '
>>    
>>
>
>  
>
>
>  
>
>>If I create a new database user with no password, then I can connect
>>    
>>
>
>  
>
>>fine, but this is obviously not something that I want to do!
>>    
>>
>
>  
>
>
>  
>
>>Does anyone know how to make tomcat / mysql/J use a password (JSP
>>    
>>
>rather
>
>  
>
>>than a stand alone java class, which is working absolutely fine).
>>    
>>
>
>  
>
>
>  
>
>>Thanks
>>    
>>
>
>  
>
>>Tom
>>    
>>
>
>  
>
>
>  
>
>
>  
>
>
>  
>
>>---------------------------------------------------------------------
>>    
>>
>
>  
>
>>To unsubscribe, e-mail: [hidden email]
>>    
>>
>
>  
>
>>For additional commands, e-mail: [hidden email]
>>    
>>
>
>  
>
>
>  
>
>
>  
>
>
>  
>
>
>  
>
>>---------------------------------------------------------------------
>>    
>>
>
>  
>
>>To unsubscribe, e-mail: [hidden email]
>>    
>>
>
>  
>
>>For additional commands, e-mail: [hidden email]
>>    
>>
>
>  
>
>
>  
>
>
>  
>
>
>  
>
>>
>>    
>>
>
>  
>
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>
>To unsubscribe, e-mail: [hidden email]
>
>For additional commands, e-mail: [hidden email]
>
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]