Connecting to hosted MySQL server with Java

Posted by Infiniti Fizz on Stack Overflow See other posts from Stack Overflow or by Infiniti Fizz
Published on 2010-04-27T11:30:31Z Indexed on 2010/04/27 11:33 UTC
Read the original article Hit count: 266

Hi,

I've been recently trying to connect to a hosted MySQL using Java but can't get it to work. I can connect to a local MySQL with localhost using:

connect = DriverManager.getConnection("jdbc:mysql://localhost/lego?"
                + "user=******&password=*******");

(Replacing the astrisks withmy username and password)

I can connect to the hosted MySQL database fine with PHP using:

mysql_connect('mysql.hosts.co.uk','******','**********');
mysql_select_db('test');

My problem is, I cannot connect via Java. I have an Exception which is caught if the connection doesn't work and this is always printed out.

Any ideas why it isn't working? Am I doing something wrong?

Thanks for your time,

InfinitiFizz

© Stack Overflow or respective owner

Related posts about mysql

Related posts about java