Hello,

I'm trying to get Tomcat and MySQL to connect. I have the following 
installations:

Tomcat V5.5.26
MySQL V5.0
mysql connector 5.1.5 from the mysql site (copied the jar to <tomcat>\common\lib

I've tried following the directions from the tomcat dist and from the mysql 
dist but I always get can't connect exceptions when I start tomcat.

In mysql I've created a user=javauser with password=javadude and I created a 
database called javatest with one table and some data in the table.
I can connect to the database from the console using "C:> mysql -u javauser -p" 
and I can then connect to the javatest DB and select * from the table works 
fine.

Then I added the following to in the <tomcat>/conf/context.xml file

<Context path="/db-servlet" docBase="db-servlet" debug="5" reloadable="true" 
crossContext="true">

   <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"

               maxActive="100" maxIdle="30" maxWait="10000"

               username="javauser" password="javadude" 
driverClassName="com.mysql.jdbc.Driver"

               url="jdbc:mysql://localhost:3306/javatest"/>

</Context>



And I stop tomcat, and when I restart tomcat I get the following in the 
catalina log:



...

INFO: Stopping Coyote HTTP/1.1 on http-8080

Feb 23, 2008 8:31:19 AM org.apache.catalina.core.AprLifecycleListener 
lifecycleEvent

INFO: Failed shutdown of Apache Portable Runtime

Feb 23, 2008 8:37:40 AM org.apache.catalina.startup.Catalina stopServer

SEVERE: Catalina.stop: 

java.net.ConnectException: Connection refused: connect

      at java.net.PlainSocketImpl.socketConnect(Native Method)

      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

      at java.net.Socket.connect(Socket.java:520)

      at java.net.Socket.connect(Socket.java:470)

      at java.net.Socket.<init>(Socket.java:367)

      at java.net.Socket.<init>(Socket.java:180)

      at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:395)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:585)

      at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:344)

      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:435)





So why the connection refused?



Any help is appreciated.



Thanks,

Kevin




Reply via email to