title: Java - Unable to connect to MySQL Database from Cpanel (godaddy). (Error: java.sql.SQLException: Access denied for user ')
body: <p>I am unable to connect to the database on my website. The user account has permissions and the user name and password are correct. The only thing that could be wrong is the link I am using for the database because I am just doing "http://" as my link. I am assuming the database is there. Godaddy cPanel portal will not show me where it directly is at.</p>
  
  <p>I do not want to do localhost, I want to connect from Java to an actual database on my cPanel.</p>
  
  <p><strong><em>NOT actual credentials.</em></strong></p>
  
  <p>In output it says:</p>
  
  <pre><code>run: Error: java.sql.SQLException: Access denied for user 'usertest'@'test.com' (using password: YES) java.lang.NullPointerException BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>
  
  <p>Code:</p>
  
  <p>Main:</p>
  
  <pre><code>package main;
  
  public class main {
  
  public static void main(String[] args) {
      db connect = new db();
      connect.getData();
  }
  
  }
  </code></pre>
  
  <p>db:</p>
  
  <pre><code>package main;
  import java.sql.*;
  
  public class db {
  
  private Connection con;
  private Statement st;
  private ResultSet rs;
  
  public db(){
      try{
          Class.forName("com.mysql.jdbc.Driver");
  
          con = DriverManager.getConnection("jdbc:mysql://","usertest","test1");
          st = con.createStatement();
  
      }catch(Exception ex){
              System.out.println("Error: "+ex);
      }
  }
  
  public void getData() {
      try{
  
          String query = "select * from persons";
          rs = st.executeQuery(query);
          System.out.println("Records from Database");
          while(rs.next());
          String name= rs.getString("name");
          String age = rs.getString("age");
          System.out.println("Name: "+name+" "+"Age"+age);
  
      }catch(Exception ex){
          System.out.println(ex);
      }
  }
  }
  </code></pre>