java.net.ConnectException: Connection refused: connect
Some distributions of mysql configure it by default to use named pipes
w/o a port listening at 3306. It's mainly for security reasons, but can
be a real PITA when your application requires a TCP/IP port. Check the
parameters MySQL was started with against the list available at
http://dev.mysql.com/doc/refman/5.0/en/server-options.html The netstat
command should also be of help in showing whether mysql is listening on
a TCP/IP port or not. Individual systems vary, but to help you get
started this works on my Mandriva system: netstat -tl. Once you have
that fixed and restart mysql, tomcat should be able to connect.
BTW don't use the autoReconnect=true url option as suggested by another
poster. It only tells the driver to attempt to reestablish the
connection if it fails for some reason, but not until you've
successfully gotten a connection from the pool, tried it and then have
received an error. Your better off configuring your <Resource.... />
element w/ a validatonQuery attribute like validationQuery="select 1".
With that the pool will test the connection just before your code
receives a connection, insuring it's always good.
--David
[EMAIL PROTECTED] wrote:
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
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]