PDA

View Full Version : JDBC access to Mysql 3.23



EMH_Rick_1
09-22-2004, 11:36 AM
Hey, y'all.... I need some help here, and hopefully a good soul (or a bad soul in a good mood) will help me out! :?

I am trying to access Mysql using JDBC. All I get is a "Connection refused" message. I have Linux installed in one of my home PCs, and my small application works just fine. I even installed the exact same version of Mysql, Java and Tomcat that WestHost offers, just to keep things as compatible as possible. Setting up Tomcat was fine, but I can't get the darned JDBC connection to work.

To better isolate and research this problem, I created a very small Java program, whose only purpose in life is to connect to the database and display the contents of a test table, and I am changing all possible settings in Mysql, trying to make it work, and so far nothing, nada, zilch... same error over and over again - so it's nothing on Tomcat. I tested the same thing in my home Linux box, and it works fine.

The fact that the program works on my local machine indicates that some configuration is out of whack in my WestHost VPS, and I can tell you right off the bat what the problem is NOT:

- It's not bypassing the "skip-networking" in the my.cnf file. I already tried that.
- User and password are checked and correct ( I am assuming that Mysql and Tomcat are in localhost, which I think it's safe to say is a fact )
- It's not any other connection information - the driver name is correct, the classpath is initialized properly.
- Oh and by the way, I DID upload the JDBC driver and its location is in the classpath
- TCP/IP access is NOT enabled in my Mysql, but since the connection is coming from localhost, that shouldn't be necessary. Besides, PHP can access Mysql fine, which shows that Mysql is responding to a connection originated locally.

So, this is not really a generic JDBC/Mysql question, it's a question regarding JDBC/Mysql in WestHost.

I contacted their user support, and even though they were quick to respond and corteous, JDBC connections "are not supported at this time", as the manual so eloquently puts it. :cry:

HELP!

Thanks :)
Rick

jalal
09-22-2004, 01:27 PM
Hmm, you seem to have covered most of the bases here...

Just a couple of thoughts:

You could turn on MySQL logging and see if there are any messages of interest:
" MySQL Logging, this is turned on in the /etc/my.cnf file, look for the line: log = /dev/null and change it to: log = /var/log/mysqld.log There is also a MySQL error file, to found at /var/lib/mysql/mydomain.com.err, but I'm not sure what controls this."

Remember changes to MySQL config require restarting the MySQL daemon.

You say PHP access works, but not JDBC, is that using the same name/password? Are the grant tables in MySQL correctly setup?

Just some ideas. And also, you maybe better off asking this question in the MySQL forums. Many people don't look this far down the page in the forum list (I'm just a bit bored this evening) and so might miss it "down here".

Good luck and let us know if you solve it.

EMH_Rick_1
09-22-2004, 02:51 PM
Hey, jalal...

Thanks for the reply. I'm really baffled by this. I will re-post my question is the Mysql forum (is there one?!). As you can see I just started posting in this forum....

Cheers.
Rick

qyuan
06-15-2007, 01:58 PM
JDBC always gives me a "connection refused" while shell connection using the same username/password is fine. It is a really roadblocker? Any success by any one? Thanks,

Zabby
07-02-2007, 08:51 AM
I have the exact same issues as above. Anyone found a solution to this or can offer new insight?

rolling
07-02-2007, 10:58 AM
A quick guess would be that localhost does not resolve to your VPS, but the parent server. Try putting your domain name instead.

epastoor
08-07-2007, 01:13 PM
you need to have your mysql connector installed in the common/lib directory. You then need to restart tomcat so that both mysql and tomcat have this loaded. It won't work anywhere else I don't believe.