cannot setup JNDI with MySQL

2005-10-06 Thread John Cherouvim

Hello

I've been trying to setup a mysql connection pool using JNDI as shown in 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

But no luck.

I never get to see the datasource registered Tomcat Administration Tool.
I've included in server.xml the following lines somewhere inside the 
 .. 




factory 
org.apache.commons.dbcp.BasicDataSourceFactory 
driverClassName 
com.mysql.jdbc.Driver 
url 
jdbc:mysql://localhost:3306/dea?autoReconnect=true 


username myusername 
password mypassword 
maxActive 20 
maxIdle 10 
maxWait 40 



I have Tomcat/5.0.28

And the following files in common\lib
mysql-connector-java-3.1.10-bin.jar
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar
*

*What I get in tomcat\logs\stdout.log is:
NotifyUtil::java.net.ConnectException: Connection refused: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
   at java.net.Socket.connect(Socket.java:425)
   at java.net.Socket.connect(Socket.java:375)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:366)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:582)
   at sun.net.www.http.HttpClient.(HttpClient.java:292)
   at sun.net.www.http.HttpClient.(HttpClient.java:253)
   at sun.net.www.http.HttpClient.New(HttpClient.java:321)
   at sun.net.www.http.HttpClient.New(HttpClient.java:306)
   at sun.net.www.http.HttpClient.New(HttpClient.java:301)
   at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:469)
   at 
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:460)
   at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:516)
   at 
org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237)



What did I miss? I've even tried setting up the JNDI in the 
conf\Catalina\localhost\myapp.xml
And also tried  instead of 


I also tried all that with the org.gjt.mm.mysql.Driver

Regards,
I.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cannot setup JNDI with MySQL

2005-10-06 Thread andy gordon
John, 
 
Possibly the following will help as it is listed in the 5.5 JDBC DataSource 
html page in the User guide: 
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 

"Please note that JNDI resource configuration has changed somewhat between 
Tomcat 5.0.x and Tomcat 5.5.x. You will most likely need to modify your JNDI 
resource configurations to match the syntax in the example below in order to 
make them work in Tomcat 5.5.x" 

 

With that said you can replace your specified parameters with the following 
from the mysql section of that page. 

 
  

Hope this helps
 
- andy

John Cherouvim <[EMAIL PROTECTED]> wrote:
Hello

I've been trying to setup a mysql connection pool using JNDI as shown in 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
But no luck.

I never get to see the datasource registered Tomcat Administration Tool.
I've included in server.xml the following lines somewhere inside the 
.. 




factory 
org.apache.commons.dbcp.BasicDataSourceFactory 


driverClassName 
com.mysql.jdbc.Driver 


url 
jdbc:mysql://localhost:3306/dea?autoReconnect=true 



username myusername 


password mypassword 


maxActive 20 


maxIdle 10 


maxWait 40 




I have Tomcat/5.0.28

And the following files in common\lib
mysql-connector-java-3.1.10-bin.jar
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar
*

*What I get in tomcat\logs\stdout.log is:
NotifyUtil::java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
at java.net.Socket.connect(Socket.java:425)
at java.net.Socket.connect(Socket.java:375)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:366)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:582)
at sun.net.www.http.HttpClient.(HttpClient.java:292)
at sun.net.www.http.HttpClient.(HttpClient.java:253)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:301)
at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:469)
at 
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:460)
at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:516)
at 
org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237)


What did I miss? I've even tried setting up the JNDI in the 
conf\Catalina\localhost\myapp.xml
And also tried instead of 

I also tried all that with the org.gjt.mm.mysql.Driver

Regards,
I.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 

Re: cannot setup JNDI with MySQL

2005-10-06 Thread andy gordon
One more thing and i may have missed it in your note: Did you say you placed 
mysql's jar file in the common\lib directory ?

John Cherouvim <[EMAIL PROTECTED]> wrote:Hello

I've been trying to setup a mysql connection pool using JNDI as shown in 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
But no luck.

I never get to see the datasource registered Tomcat Administration Tool.
I've included in server.xml the following lines somewhere inside the 
.. 




factory 
org.apache.commons.dbcp.BasicDataSourceFactory 


driverClassName 
com.mysql.jdbc.Driver 


url 
jdbc:mysql://localhost:3306/dea?autoReconnect=true 



username myusername 


password mypassword 


maxActive 20 


maxIdle 10 


maxWait 40 




I have Tomcat/5.0.28

And the following files in common\lib
mysql-connector-java-3.1.10-bin.jar
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar
*

*What I get in tomcat\logs\stdout.log is:
NotifyUtil::java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
at java.net.Socket.connect(Socket.java:425)
at java.net.Socket.connect(Socket.java:375)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:366)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:582)
at sun.net.www.http.HttpClient.(HttpClient.java:292)
at sun.net.www.http.HttpClient.(HttpClient.java:253)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:301)
at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:469)
at 
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:460)
at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:516)
at 
org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237)


What did I miss? I've even tried setting up the JNDI in the 
conf\Catalina\localhost\myapp.xml
And also tried instead of 

I also tried all that with the org.gjt.mm.mysql.Driver

Regards,
I.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 

Re: cannot setup JNDI with MySQL

2005-10-06 Thread Hassan Schroeder
John Cherouvim wrote:

> I've been trying to setup a mysql connection pool using JNDI as shown in
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
> But no luck.

> *What I get in tomcat\logs\stdout.log is:
> NotifyUtil::java.net.ConnectException: Connection refused: connect
>at java.net.PlainSocketImpl.socketConnect(Native Method)

A "Connection refused" sounds like your driver config is fine but
either MySQL isn't running, it's configured with skip-networking,
or you've got a firewall/iptables/whatever issue.

Can you connect (`telnet localhost 3306`) from the command line?

-- 
Hassan Schroeder - [EMAIL PROTECTED]
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

  dream.  code.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cannot setup JNDI with MySQL

2005-10-06 Thread Andrés Glez .
The problem is not JDNI. The problem is you can't connect to MySQL. Probably 
it's you have to check your MySQL access permissions...


Can you connect to MySQL using the same parameters with another tool like 
MySQL Control Center?


- Original Message - 
From: "John Cherouvim" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, October 06, 2005 11:17 AM
Subject: cannot setup JNDI with MySQL



Hello

I've been trying to setup a mysql connection pool using JNDI as shown in 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

But no luck.

I never get to see the datasource registered Tomcat Administration Tool.
I've included in server.xml the following lines somewhere inside the 
 .. 


type="javax.sql.DataSource"/>


factory 
org.apache.commons.dbcp.BasicDataSourceFactory 
driverClassName 
com.mysql.jdbc.Driver 
url 
jdbc:mysql://localhost:3306/dea?autoReconnect=true 

username myusername 

password mypassword 


maxActive 20 
maxIdle 10 
maxWait 40 



I have Tomcat/5.0.28

And the following files in common\lib
mysql-connector-java-3.1.10-bin.jar
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar
*

*What I get in tomcat\logs\stdout.log is:
NotifyUtil::java.net.ConnectException: Connection refused: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
   at java.net.Socket.connect(Socket.java:425)
   at java.net.Socket.connect(Socket.java:375)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:366)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:582)
   at sun.net.www.http.HttpClient.(HttpClient.java:292)
   at sun.net.www.http.HttpClient.(HttpClient.java:253)
   at sun.net.www.http.HttpClient.New(HttpClient.java:321)
   at sun.net.www.http.HttpClient.New(HttpClient.java:306)
   at sun.net.www.http.HttpClient.New(HttpClient.java:301)
   at 
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:469)
   at 
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:460)
   at 
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:516)
   at 
org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237)



What did I miss? I've even tried setting up the JNDI in the 
conf\Catalina\localhost\myapp.xml
And also tried  instead of 


I also tried all that with the org.gjt.mm.mysql.Driver

Regards,
I.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cannot setup JNDI with MySQL

2005-10-06 Thread John Cherouvim

Thanks for your answers.

I can connect to MySQL using any mysql tool and even with telnet 
localhost 3306 from the command line. I even tried connecting to another 
mysql server running on another pc in my LAN but nothing.


@andy: yes I have placed mysql-connector-java-3.1.10-bin.jar in 
common\lib and I also tried with different (older) versions. I've been 
leaving only one of them of course each time I tried.


I finally managed to solve the problem.
I needed to place:
   
   
  url 
jdbc:mysql://localhost:3306/dea?autoReconnect=true 


  password john 
  maxActive 4 
  maxWait 5000 
  driverClassName 
com.mysql.jdbc.Driver 

  maxIdle 2 
  username john 
   

somewhere in the  element of my server.xml.
The tutorial at 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html 
says:
"Add this in between the || tag of the examples context and 
the || tag closing the localhost definition."


Which I cannot understand where exctly it means. I was always trying to 
place it somewhere inside the  element which was not working for me.


I solved the problem by adding the DataSource from the administration 
tool of tomcat and then I went to server.xml to see how it did it.


Regards,
J.


Hassan Schroeder wrote:


John Cherouvim wrote:

 


I've been trying to setup a mysql connection pool using JNDI as shown in
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
But no luck.
   



 


*What I get in tomcat\logs\stdout.log is:
NotifyUtil::java.net.ConnectException: Connection refused: connect
  at java.net.PlainSocketImpl.socketConnect(Native Method)
   



A "Connection refused" sounds like your driver config is fine but
either MySQL isn't running, it's configured with skip-networking,
or you've got a firewall/iptables/whatever issue.

Can you connect (`telnet localhost 3306`) from the command line?

 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cannot setup JNDI with MySQL

2005-10-06 Thread David Smith
Hmmm...  I haven't read that tutorial in a while but if that's what it
says, it's wrong.  The  and  elements should
be placed between  and  tags of your context xml
file.  That would make the resource only available to that one
application as opposed to being available to all webapps in that Tomcat
instance.

--David

John Cherouvim wrote:

> Thanks for your answers.
>
> I can connect to MySQL using any mysql tool and even with telnet
> localhost 3306 from the command line. I even tried connecting to
> another mysql server running on another pc in my LAN but nothing.
>
> @andy: yes I have placed mysql-connector-java-3.1.10-bin.jar in
> common\lib and I also tried with different (older) versions. I've been
> leaving only one of them of course each time I tried.
>
> I finally managed to solve the problem.
> I needed to place:
>
>
>   url
> jdbc:mysql://localhost:3306/dea?autoReconnect=true
> 
>   password john 
>   maxActive 4 
>   maxWait 5000 
>   driverClassName
> com.mysql.jdbc.Driver 
>   maxIdle 2 
>   username john 
>
>
> somewhere in the  element of my server.xml.
> The tutorial at
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
> says:
> "Add this in between the || tag of the examples context and
> the || tag closing the localhost definition."
>
> Which I cannot understand where exctly it means. I was always trying
> to place it somewhere inside the  element which was not working
> for me.
>
> I solved the problem by adding the DataSource from the administration
> tool of tomcat and then I went to server.xml to see how it did it.
>
> Regards,
> J.
>
>
> Hassan Schroeder wrote:
>
>> John Cherouvim wrote:
>>
>>  
>>
>>> I've been trying to setup a mysql connection pool using JNDI as
>>> shown in
>>> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>>>
>>> But no luck.
>>>   
>>
>>
>>  
>>
>>> *What I get in tomcat\logs\stdout.log is:
>>> NotifyUtil::java.net.ConnectException: Connection refused: connect
>>>   at java.net.PlainSocketImpl.socketConnect(Native Method)
>>>   
>>
>>
>> A "Connection refused" sounds like your driver config is fine but
>> either MySQL isn't running, it's configured with skip-networking,
>> or you've got a firewall/iptables/whatever issue.
>>
>> Can you connect (`telnet localhost 3306`) from the command line?
>>
>>  
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
===
David Smith
Network Operations Supervisor
Department of Entomology
College of Agriculture & Life Sciences
Cornell University
2132 Comstock Hall
Ithaca, NY  14853
Phone: 607.255.9571
Fax: 607.255.0939


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cannot setup JNDI with MySQL

2005-10-06 Thread Darryl L. Miles


"localhost" has special meaning to the MySQL command line tool, this 
uses the Unix Domain socket for transport, like /tmp/mysql.sock this 
does not work with Java I don't believe there is any API to access Unix 
Domain sockets.


Confirm:

mysql -h localhost -u username -ppassword database

AND

mysql -h 127.0.0.1 -u username -ppassword database


both work.. the first uses Unix Domain sockets the 2nd TCPIP socket, 
same as the Java JDBC driver uses.  Maybe "netstat -ton | grep 3306"  
can help you find where MySQL is connected with TCPIP.  If you can't 
find it you need to look at my.cnf from mysql's var direction, maybe 
/opt/mysql/var/my.cnf and check you DONT have "skip-networking" set.  
Then check for "port=" and "bind=" values if its running on the 
non-standard settings than INADDR_ANY:3306.




My question, in my (5.5.9) $CATALINE_HOME/common/lib I have:

commons-el.jar
jasper-compiler.jar
jasper-compiler-jdt.jar
jasper-runtime.jar
jsp-api.jar
mysql-connector-java-3.1.10-bin.jar
naming-factory-dbcp.jar
naming-factory.jar
naming-resources.jar
servlet-api.jar

But you also have:
commons-collections-3.1.jar
commons-dbcp-1.2.1.jar
commons-pool-1.2.jar

I am having problems with "naming-factory-dbcp.jar" I'm not sure which 
base version it is for a start and it does not seem to re-use the 
connections in the pool.  Is it possible to override the version shipped 
with TC adding a few files and changing the class path in the  
to the official Apache one ?


Do you know which version of DBCP is shipped with TC 5.5.9 ?


Thanks

Darryl

--
Darryl L. Miles



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]