You are not logged in.

#1 2006-03-13 20:59:05

rinzai
Member
From: Sofia || München || Garching
Registered: 2005-03-04
Posts: 21

JSP/JDBC connectivity problem

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 smile

PS. Perhaps I need J2EE hmm
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

#2 2006-03-15 08:47:43

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: JSP/JDBC connectivity problem

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

#3 2006-03-15 11:15:20

rinzai
Member
From: Sofia || München || Garching
Registered: 2005-03-04
Posts: 21

Re: JSP/JDBC connectivity problem

Well I've tried both with the same results. The thing is I've got it to work with Postgresql hmm 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

#4 2006-03-21 06:45:06

Haiyadragon
Member
Registered: 2006-03-21
Posts: 56

Re: JSP/JDBC connectivity problem

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

#5 2006-03-29 21:11:27

rinzai
Member
From: Sofia || München || Garching
Registered: 2005-03-04
Posts: 21

Re: JSP/JDBC connectivity problem

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 smile


Being able to read someone else's code is a *good thing*. Not a fundamental right.

Offline

#6 2006-04-08 07:35:31

drojid
Member
Registered: 2005-02-21
Posts: 13

Re: JSP/JDBC connectivity problem

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

#7 2006-09-16 16:11:19

rdoggsv
Member
From: /home
Registered: 2005-06-24
Posts: 79
Website

Re: JSP/JDBC connectivity problem

drojid wrote:

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.. lol

Offline

#8 2008-04-04 16:07:52

PierreAd
Member
Registered: 2007-05-07
Posts: 19

Re: JSP/JDBC connectivity problem

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 smile

PierreAd

Offline

Board footer

Powered by FluxBB