connecting to remote MySQL server using JDBC issue

I am working on a dynamic webapp on eclipse and is trying to access a remote MySQL database. I made sure that all the information is correct. However I can't seem to connect to it. Here's my getConnection method:

public static Connection getConnection() throws SQLException {
        Connection conn = null;
            String url = "jdbc:mysql://";
            String user = "username";
            String password = "password";
            conn =  DriverManager.getConnection(url, user, password);
        }catch(ClassNotFoundException e){
        }catch(InstantiationException e){
        }catch(IllegalAccessException e){
            return conn;


I am trying to see what the error is but because this is a web app, I can't see that system.out.println anywhere, so it's kind of hard for me to debug with this. Any suggestions on how to debug?


Is your MySQL server accessible from out of the server? I am asking because it is possible to disable external connection for MySQL server, more info is here.

Your credentials are OK (at least its format).

Otherwise, you create Class.forName("com.mysql.jdbc.Driver").newInstance(); but you don't assign it to conn variable.

In web applications, System.out prints to the server's logs file. If you are using tomcat, see logs directory inside tomcat's base directory.

If you are still struggling to see the System out in logs, try to test the class from standalone java class, you will clearly see what the problem is.

Need Your Help

When using Spring and Maven, what is the best way to deploy the code to the server?

java spring deployment maven

I have a project that uses Spring. Every time I deploy, I run the maven goal "package", which runs all the tests and creates the war file. Then I manually use an ftp program to copy the war file to...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.