You are not logged in.
Pages: 1
Hi, I'm doing my first steps in JSP development and I've stumbled upon the following problem when trying to connect to a MYSQL database
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused
In my web.xml file I have
<context-param>
<param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
<param-value>jdbc:mysql://localhost:3306/testdb,com.mysql.jdbc.Driver,root,rootpass</param-value>
</context-param>
At first I thought it had something to do with the password but I connect to the databse without a problem from the mysql command-line and from knoda.
Thanks in advance
PS. Perhaps I need J2EE
PPS. I'm using the JRE 1.5.0_06 from [extra] and MySQL Connector/J 3.1.12
PPS. Crap, it's probably something really stupid. :?
Being able to read someone else's code is a *good thing*. Not a fundamental right.
Offline
Are you sure your JDBC URL is correct? I remember using a line like
jdbc:mysql://<serveraddress>:<port>/<dbname>?user=<username>&password=<password>
A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.
Offline
Well I've tried both with the same results. The thing is I've got it to work with Postgresql which is really odd.
Here's the dataSource parameter in web.xml:
jdbc:postgresql://localhost:5432/employee,org.postgresql.Driver,postgres
Being able to read someone else's code is a *good thing*. Not a fundamental right.
Offline
I think by default Mysql doesn't listen to tcp connections. You should remove skip-networking from my.cnf (and restart mysql).
I might be totally wrong, it's been a while.
Offline
This should be it. This is what my.conf has to say about it:
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
skip-networking
But I'll try it tomorrow morning because it's getting late and I'm not in the mood for editing code
Being able to read someone else's code is a *good thing*. Not a fundamental right.
Offline
If the problem still exists, try adding
mysqld: ALL
(or at least localhost) to /etc/hosts.allow as by default no tcpip connection is allowed to mysqld in Arch. I haven't noticed this for a while, because all of my db frontends fallback to socket connection silently, that mysql-connector-java does not support.
Offline
If the problem still exists, try adding
mysqld: ALL
(or at least localhost) to /etc/hosts.allow as by default no tcpip connection is allowed to mysqld in Arch. I haven't noticed this for a while, because all of my db frontends fallback to socket connection silently, that mysql-connector-java does not support.
Thank you !! i've been looking for half an hour about this subject and then i decided to come look in here, i was thinking it was Jconnector problems so i went to mysql support - java support , etc , no luck in there..
Offline
Yes thanks a lot ! Did the same as rdoggsv, I searched over mysql and java forums, but nothing.. It was a configuration problem then !
Thank you
PierreAd
Offline
Pages: 1